kd-lane-chart-v3 0.0.9 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -2929,7 +2929,7 @@ const _hoisted_2$6 = { class: "legend-content" };
2929
2929
  const _hoisted_3$5 = { class: "scale-left" };
2930
2930
  const _hoisted_4$5 = ["onClick"];
2931
2931
  const _hoisted_5$4 = { class: "legend-line-item-top" };
2932
- const _hoisted_6$4 = { class: "legend-text" };
2932
+ const _hoisted_6$3 = { class: "legend-text" };
2933
2933
  const _hoisted_7$3 = {
2934
2934
  key: 0,
2935
2935
  class: "legend-data"
@@ -2959,7 +2959,7 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
2959
2959
  class: normalizeClass(["legend-color", legend.lineType]),
2960
2960
  style: normalizeStyle({ borderBottom: `2px ${legend.lineType} ${legend.color}` })
2961
2961
  }, null, 6),
2962
- createElementVNode("div", _hoisted_6$4, toDisplayString(legend.label), 1)
2962
+ createElementVNode("div", _hoisted_6$3, toDisplayString(legend.label), 1)
2963
2963
  ]),
2964
2964
  $props.formCache.displayType == "header" ? (openBlock(), createElementBlock("div", _hoisted_7$3, toDisplayString(legend.data), 1)) : createCommentVNode("", true)
2965
2965
  ], 12, _hoisted_4$5);
@@ -4072,7 +4072,7 @@ const _hoisted_5$3 = {
4072
4072
  key: 0,
4073
4073
  class: "kd-lane-chart-lane-container-echart"
4074
4074
  };
4075
- const _hoisted_6$3 = ["onMousedown"];
4075
+ const _hoisted_6$2 = ["onMousedown"];
4076
4076
  const _hoisted_7$2 = ["id", "lane-id"];
4077
4077
  const _hoisted_8$1 = ["onMousedown"];
4078
4078
  const _hoisted_9$1 = {
@@ -4204,7 +4204,7 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
4204
4204
  key: 1,
4205
4205
  class: "kd-lane-resize-handle kd-lane-resize-handle-right",
4206
4206
  onMousedown: ($event) => $options.startResize($event, lane, "right")
4207
- }, null, 40, _hoisted_6$3)) : createCommentVNode("", true)
4207
+ }, null, 40, _hoisted_6$2)) : createCommentVNode("", true)
4208
4208
  ], 64))
4209
4209
  ], 14, _hoisted_1$6);
4210
4210
  }), 128)),
@@ -4407,7 +4407,7 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
4407
4407
  }, 8, ["modelValue", "onClose"])
4408
4408
  ], 544);
4409
4409
  }
4410
- const KdLaneContainerComponent = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6], ["__scopeId", "data-v-423ed0d6"]]);
4410
+ const KdLaneContainerComponent = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6], ["__scopeId", "data-v-58d1cc31"]]);
4411
4411
  const SLIDER_GROUP_ID = "depthSliderGroup";
4412
4412
  function pad2(n) {
4413
4413
  return n < 10 ? "0" + n : "" + n;
@@ -5675,7 +5675,7 @@ const _hoisted_4$3 = {
5675
5675
  class: "chart"
5676
5676
  };
5677
5677
  const _hoisted_5$2 = { class: "label-card" };
5678
- const _hoisted_6$2 = { class: "label-row" };
5678
+ const _hoisted_6$1 = { class: "label-row" };
5679
5679
  const _hoisted_7$1 = { class: "label-row" };
5680
5680
  function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
5681
5681
  const _component_el_radio = resolveComponent("el-radio");
@@ -5711,7 +5711,7 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
5711
5711
  style: normalizeStyle($options.labelFloatStyle)
5712
5712
  }, [
5713
5713
  createElementVNode("div", _hoisted_5$2, [
5714
- createElementVNode("div", _hoisted_6$2, toDisplayString($data.labelPos.line1), 1),
5714
+ createElementVNode("div", _hoisted_6$1, toDisplayString($data.labelPos.line1), 1),
5715
5715
  createElementVNode("div", _hoisted_7$1, toDisplayString($data.labelPos.line2), 1)
5716
5716
  ])
5717
5717
  ], 4), [
@@ -6185,7 +6185,7 @@ const _hoisted_4$2 = {
6185
6185
  class: "label"
6186
6186
  };
6187
6187
  const _hoisted_5$1 = { class: "elTooltipArea" };
6188
- const _hoisted_6$1 = {
6188
+ const _hoisted_6 = {
6189
6189
  key: 7,
6190
6190
  class: "label"
6191
6191
  };
@@ -6384,7 +6384,7 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
6384
6384
  ]),
6385
6385
  _: 1
6386
6386
  }, 8, ["disabled"])) : createCommentVNode("", true),
6387
- $props.currentToolBarConfig.timeRangeSelectShow !== false ? (openBlock(), createElementBlock("div", _hoisted_6$1, "时间范围:")) : createCommentVNode("", true),
6387
+ $props.currentToolBarConfig.timeRangeSelectShow !== false ? (openBlock(), createElementBlock("div", _hoisted_6, "时间范围:")) : createCommentVNode("", true),
6388
6388
  $props.currentToolBarConfig.timeRangeSelectShow !== false ? (openBlock(), createBlock(_component_el_tooltip, {
6389
6389
  key: 8,
6390
6390
  disabled: !($data.form.axisType == "depth"),
@@ -7395,6 +7395,7 @@ const _sfc_main$2 = {
7395
7395
  // 当前右键菜单来源:'missingPoint' | 'markArea' | null
7396
7396
  currentContextMenuType: null,
7397
7397
  activeSubMenu: null,
7398
+ subMenuDirection: "right",
7398
7399
  params: [],
7399
7400
  contextItem: void 0,
7400
7401
  realTimeData: [],
@@ -8465,7 +8466,31 @@ const _sfc_main$2 = {
8465
8466
  },
8466
8467
  formatter: (series) => {
8467
8468
  var _a;
8468
- const uniqueSeries = series.filter((item) => item.seriesName !== "helper");
8469
+ const uniqueSeries = series.filter((item) => item.seriesName !== "helper").reduce((acc, current) => {
8470
+ const existingIndex = acc.findIndex(
8471
+ (item) => item.seriesName === current.seriesName
8472
+ );
8473
+ if (existingIndex === -1) {
8474
+ acc.push(current);
8475
+ } else {
8476
+ const existingItem = acc[existingIndex];
8477
+ const existingValue = Array.isArray(existingItem.value) ? existingItem.value[0] : existingItem.value;
8478
+ const currentValue = Array.isArray(current.value) ? current.value[0] : current.value;
8479
+ const existingHasValue = existingValue !== void 0 && existingValue !== null && existingValue !== "";
8480
+ const currentHasValue = currentValue !== void 0 && currentValue !== null && currentValue !== "";
8481
+ if (!existingHasValue && currentHasValue) ;
8482
+ else if (existingHasValue && !currentHasValue) {
8483
+ acc[existingIndex] = current;
8484
+ } else if (existingHasValue && currentHasValue) {
8485
+ if (Number(currentValue) > Number(existingValue)) {
8486
+ acc[existingIndex] = current;
8487
+ }
8488
+ } else {
8489
+ acc[existingIndex] = current;
8490
+ }
8491
+ }
8492
+ return acc;
8493
+ }, []);
8469
8494
  if (this.tooltipFormatter && typeof this.tooltipFormatter === "function") {
8470
8495
  let mousePositionData = null;
8471
8496
  if (uniqueSeries.length > 0) {
@@ -9168,11 +9193,21 @@ const _sfc_main$2 = {
9168
9193
  let lastValidPoint = null;
9169
9194
  let lastValidIndex = -1;
9170
9195
  let inMissingRange = false;
9196
+ let firstValidPoint = null;
9197
+ let firstValidIndex = -1;
9198
+ let hasMissingAtStart = false;
9171
9199
  for (let i = 0; i < seriesData.length; i++) {
9172
9200
  const point = seriesData[i];
9173
9201
  const value = point[0];
9174
9202
  const isValid = value !== null && value !== void 0 && value !== "" && Number.isFinite(+value);
9175
9203
  if (isValid) {
9204
+ if (firstValidPoint === null) {
9205
+ firstValidPoint = point;
9206
+ firstValidIndex = i;
9207
+ if (i > 0) {
9208
+ hasMissingAtStart = true;
9209
+ }
9210
+ }
9176
9211
  if (inMissingRange && lastValidPoint) {
9177
9212
  boundaryPoints.push({
9178
9213
  data: lastValidPoint,
@@ -9194,6 +9229,20 @@ const _sfc_main$2 = {
9194
9229
  }
9195
9230
  }
9196
9231
  }
9232
+ if (hasMissingAtStart && firstValidPoint) {
9233
+ boundaryPoints.push({
9234
+ data: firstValidPoint,
9235
+ type: "bottom",
9236
+ originalIndex: firstValidIndex
9237
+ });
9238
+ }
9239
+ if (inMissingRange && lastValidPoint) {
9240
+ boundaryPoints.push({
9241
+ data: lastValidPoint,
9242
+ type: "top",
9243
+ originalIndex: lastValidIndex
9244
+ });
9245
+ }
9197
9246
  return boundaryPoints;
9198
9247
  },
9199
9248
  async handleChartClick(e, laneId) {
@@ -9384,6 +9433,9 @@ const _sfc_main$2 = {
9384
9433
  });
9385
9434
  const scatterData = filteredPoints.map((point) => ({
9386
9435
  value: point.value,
9436
+ lineId: point.lineId,
9437
+ paramId: point.paramId,
9438
+ timestamp: point.timestamp,
9387
9439
  itemStyle: {
9388
9440
  color: point.color || "#1890ff",
9389
9441
  borderColor: "#fff",
@@ -9506,7 +9558,27 @@ const _sfc_main$2 = {
9506
9558
  }
9507
9559
  }
9508
9560
  if (clickedPoint) {
9509
- this.showContextMenu(clickedPoint, laneId, e);
9561
+ if (clickedPoint.type && (clickedPoint.type === "top" || clickedPoint.type === "bottom")) {
9562
+ this.showContextMenu(clickedPoint, laneId, e);
9563
+ } else if (clickedPoint.paramId && clickedPoint.lineId) {
9564
+ const markAreaIndex = this.findMarkAreaByPoint(clickedPoint, laneId);
9565
+ if (markAreaIndex !== -1) {
9566
+ this.currentMarkAreaIndex = markAreaIndex;
9567
+ this.currentContextMenuType = "markArea";
9568
+ this.currentPointInfo = null;
9569
+ this.currentContextMenuItems = [
9570
+ ...this.markAreaMenuConfig || [],
9571
+ { label: "删除区块", action: "deleteMarkArea" }
9572
+ ];
9573
+ this.calculateContextMenuPosition(e);
9574
+ this.contextMenuVisible = true;
9575
+ this.activeSubMenu = null;
9576
+ } else {
9577
+ this.showMarkAreaContextMenu(laneId, e);
9578
+ }
9579
+ } else {
9580
+ this.showMarkAreaContextMenu(laneId, e);
9581
+ }
9510
9582
  } else {
9511
9583
  this.showMarkAreaContextMenu(laneId, e);
9512
9584
  }
@@ -9645,12 +9717,35 @@ const _sfc_main$2 = {
9645
9717
  this.currentContextMenuType = null;
9646
9718
  this.currentContextMenuItems = [];
9647
9719
  this.activeSubMenu = null;
9720
+ this.subMenuDirection = "right";
9648
9721
  this.menuWidth = null;
9649
9722
  this.menuHeight = null;
9650
9723
  },
9651
9724
  showSubMenu(item, event) {
9652
9725
  event.stopPropagation();
9653
9726
  this.activeSubMenu = item;
9727
+ const parentMenuItem = event.currentTarget;
9728
+ this.$nextTick(() => {
9729
+ const container = document.querySelector(".kd-lane-chart-lane-container-echart");
9730
+ const subMenu = parentMenuItem == null ? void 0 : parentMenuItem.querySelector(".sub-menu");
9731
+ if (!container || !parentMenuItem || !subMenu) return;
9732
+ subMenu.style.visibility = "hidden";
9733
+ const containerRect = container.getBoundingClientRect();
9734
+ const parentRect = parentMenuItem.getBoundingClientRect();
9735
+ const subMenuWidth = subMenu.offsetWidth;
9736
+ const rightAvailable = containerRect.right - parentRect.right;
9737
+ this.subMenuDirection = rightAvailable >= subMenuWidth ? "right" : "left";
9738
+ subMenu.style.visibility = "";
9739
+ });
9740
+ },
9741
+ getSubMenuStyle() {
9742
+ return {
9743
+ left: this.subMenuDirection === "right" ? "100%" : "auto",
9744
+ right: this.subMenuDirection === "right" ? "auto" : "100%",
9745
+ top: 0,
9746
+ marginLeft: this.subMenuDirection === "right" ? "4px" : "auto",
9747
+ marginRight: this.subMenuDirection === "right" ? "auto" : "4px"
9748
+ };
9654
9749
  },
9655
9750
  handleContextMenuItemClick(item) {
9656
9751
  if (item.action === "deleteMarkArea") {
@@ -9695,6 +9790,7 @@ const _sfc_main$2 = {
9695
9790
  return;
9696
9791
  }
9697
9792
  const { topPoint, bottomPoint } = this.findBoundaryPointPair(currentPoint);
9793
+ console.log("获取到的起始点和结束点", topPoint, bottomPoint);
9698
9794
  this.$emit("missingPointMenuItemClick", {
9699
9795
  pointInfo: currentPoint,
9700
9796
  menuItem: item,
@@ -9766,6 +9862,11 @@ const _sfc_main$2 = {
9766
9862
  );
9767
9863
  if (nextPoint) {
9768
9864
  bottomPoint = nextPoint;
9865
+ } else {
9866
+ bottomPoint = this.findBoundaryPointFromRealTimeData(
9867
+ currentPoint,
9868
+ "bottom"
9869
+ );
9769
9870
  }
9770
9871
  } else if (currentPoint.type === "bottom" && bottomPoint) {
9771
9872
  const prevPoint = option.series.filter((s) => s.type === "scatter").flatMap((s) => s.data || []).find(
@@ -9773,10 +9874,110 @@ const _sfc_main$2 = {
9773
9874
  );
9774
9875
  if (prevPoint) {
9775
9876
  topPoint = prevPoint;
9877
+ } else {
9878
+ topPoint = this.findBoundaryPointFromRealTimeData(currentPoint, "top");
9776
9879
  }
9777
9880
  }
9778
9881
  return { topPoint, bottomPoint };
9779
9882
  },
9883
+ findBoundaryPointFromRealTimeData(currentPoint, targetType) {
9884
+ const axisKey = this.currentToolBarConfig.axisTypeList && this.currentToolBarConfig.axisTypeList[this.formCache.axisType] || (this.formCache.axisType === "time" ? "time" : "depth");
9885
+ const currentYValue = currentPoint.value[1];
9886
+ const paramId = currentPoint.paramId;
9887
+ let searchStartIndex = -1;
9888
+ const tolerance = this.formCache.axisType === "depth" ? 0.01 : 1e3;
9889
+ for (let i = 0; i < this.realTimeData.length; i++) {
9890
+ const item = this.realTimeData[i];
9891
+ let itemYValue = item[axisKey];
9892
+ if (this.formCache.axisType !== "depth") {
9893
+ itemYValue = this.toMillisecondTimestamp(itemYValue);
9894
+ } else {
9895
+ itemYValue = Number(itemYValue);
9896
+ }
9897
+ if (Math.abs(itemYValue - currentYValue) < tolerance) {
9898
+ searchStartIndex = i;
9899
+ break;
9900
+ }
9901
+ }
9902
+ if (searchStartIndex === -1) return null;
9903
+ let boundaryPoint = null;
9904
+ if (targetType === "bottom") {
9905
+ for (let i = searchStartIndex + 1; i < this.realTimeData.length; i++) {
9906
+ const item = this.realTimeData[i];
9907
+ const value = item[paramId];
9908
+ if (value !== null && value !== void 0 && value !== "" && Number.isFinite(+value)) {
9909
+ let itemYValue = item[axisKey];
9910
+ if (this.formCache.axisType !== "depth") {
9911
+ itemYValue = this.toMillisecondTimestamp(itemYValue);
9912
+ } else {
9913
+ itemYValue = Number(itemYValue);
9914
+ }
9915
+ boundaryPoint = {
9916
+ value: [value, itemYValue],
9917
+ lineId: currentPoint.lineId,
9918
+ paramId,
9919
+ type: "bottom",
9920
+ originalIndex: i
9921
+ };
9922
+ break;
9923
+ }
9924
+ }
9925
+ if (!boundaryPoint) {
9926
+ const lastItem = this.realTimeData[this.realTimeData.length - 1];
9927
+ let lastYValue = lastItem[axisKey];
9928
+ if (this.formCache.axisType !== "depth") {
9929
+ lastYValue = this.toMillisecondTimestamp(lastYValue);
9930
+ } else {
9931
+ lastYValue = Number(lastYValue);
9932
+ }
9933
+ boundaryPoint = {
9934
+ value: [lastItem[paramId], lastYValue],
9935
+ lineId: currentPoint.lineId,
9936
+ paramId,
9937
+ type: "bottom",
9938
+ originalIndex: this.realTimeData.length - 1
9939
+ };
9940
+ }
9941
+ } else {
9942
+ for (let i = searchStartIndex - 1; i >= 0; i--) {
9943
+ const item = this.realTimeData[i];
9944
+ const value = item[paramId];
9945
+ if (value !== null && value !== void 0 && value !== "" && Number.isFinite(+value)) {
9946
+ let itemYValue = item[axisKey];
9947
+ if (this.formCache.axisType !== "depth") {
9948
+ itemYValue = this.toMillisecondTimestamp(itemYValue);
9949
+ } else {
9950
+ itemYValue = Number(itemYValue);
9951
+ }
9952
+ boundaryPoint = {
9953
+ value: [value, itemYValue],
9954
+ lineId: currentPoint.lineId,
9955
+ paramId,
9956
+ type: "top",
9957
+ originalIndex: i
9958
+ };
9959
+ break;
9960
+ }
9961
+ }
9962
+ if (!boundaryPoint) {
9963
+ const firstItem = this.realTimeData[0];
9964
+ let firstYValue = firstItem[axisKey];
9965
+ if (this.formCache.axisType !== "depth") {
9966
+ firstYValue = this.toMillisecondTimestamp(firstYValue);
9967
+ } else {
9968
+ firstYValue = Number(firstYValue);
9969
+ }
9970
+ boundaryPoint = {
9971
+ value: [firstItem[paramId], firstYValue],
9972
+ lineId: currentPoint.lineId,
9973
+ paramId,
9974
+ type: "top",
9975
+ originalIndex: 0
9976
+ };
9977
+ }
9978
+ }
9979
+ return boundaryPoint;
9980
+ },
9780
9981
  // 获取Y轴标签格式化函数
9781
9982
  getYAxisLabelFormatter(isTimeLane, dataGroups, groupIndex, groupMin, groupMax, axisKey) {
9782
9983
  return (value) => {
@@ -10972,13 +11173,8 @@ const _hoisted_2$2 = {
10972
11173
  ref: "targetDom"
10973
11174
  };
10974
11175
  const _hoisted_3$1 = ["onMouseenter", "onClick"];
10975
- const _hoisted_4$1 = {
10976
- key: 0,
10977
- class: "context-menu sub-menu",
10978
- style: { left: "100%", top: 0 }
10979
- };
11176
+ const _hoisted_4$1 = ["onClick"];
10980
11177
  const _hoisted_5 = ["onClick"];
10981
- const _hoisted_6 = ["onClick"];
10982
11178
  function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
10983
11179
  const _component_resizeEcharts = resolveComponent("resizeEcharts");
10984
11180
  const _component_chartContainer = resolveComponent("chartContainer");
@@ -11091,7 +11287,11 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
11091
11287
  }, [
11092
11288
  createElementVNode("span", null, toDisplayString(item.label), 1),
11093
11289
  _cache[8] || (_cache[8] = createElementVNode("span", { class: "arrow" }, "›", -1)),
11094
- $data.activeSubMenu === item ? (openBlock(), createElementBlock("div", _hoisted_4$1, [
11290
+ $data.activeSubMenu === item ? (openBlock(), createElementBlock("div", {
11291
+ key: 0,
11292
+ class: "context-menu sub-menu",
11293
+ style: normalizeStyle($options.getSubMenuStyle())
11294
+ }, [
11095
11295
  (openBlock(true), createElementBlock(Fragment, null, renderList(item.children, (child, childIndex) => {
11096
11296
  return openBlock(), createElementBlock("div", {
11097
11297
  key: childIndex,
@@ -11099,16 +11299,16 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
11099
11299
  onClick: ($event) => $options.handleContextMenuItemClick(child)
11100
11300
  }, [
11101
11301
  createElementVNode("span", null, toDisplayString(child.label), 1)
11102
- ], 8, _hoisted_5);
11302
+ ], 8, _hoisted_4$1);
11103
11303
  }), 128))
11104
- ])) : createCommentVNode("", true)
11304
+ ], 4)) : createCommentVNode("", true)
11105
11305
  ], 40, _hoisted_3$1)) : (openBlock(), createElementBlock("div", {
11106
11306
  key: 1,
11107
11307
  class: "context-menu-item",
11108
11308
  onClick: ($event) => $options.handleContextMenuItemClick(item)
11109
11309
  }, [
11110
11310
  createElementVNode("span", null, toDisplayString(item.label), 1)
11111
- ], 8, _hoisted_6))
11311
+ ], 8, _hoisted_5))
11112
11312
  ], 64);
11113
11313
  }), 128))
11114
11314
  ], 4)
@@ -11117,7 +11317,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
11117
11317
  ])
11118
11318
  ], 512);
11119
11319
  }
11120
- const chartContainer = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__scopeId", "data-v-1fceddd1"]]);
11320
+ const chartContainer = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__scopeId", "data-v-d90c5e39"]]);
11121
11321
  const _sfc_main$1 = {
11122
11322
  name: "ParameterPanel",
11123
11323
  props: {