kd-lane-chart-v3 0.1.1 → 0.1.3

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
@@ -262,7 +262,7 @@ const _sfc_main$d = {
262
262
  })
263
263
  },
264
264
  parentElement: {
265
- type: Object,
265
+ type: HTMLElement,
266
266
  default: null
267
267
  }
268
268
  },
@@ -371,7 +371,7 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
371
371
  ])
372
372
  ]);
373
373
  }
374
- const VueSimpleContextMenu = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$d], ["__scopeId", "data-v-b1e7434d"]]);
374
+ const VueSimpleContextMenu = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$d], ["__scopeId", "data-v-5e769d89"]]);
375
375
  class CustomStrategy {
376
376
  constructor(strategy) {
377
377
  this.strategy = strategy;
@@ -2430,7 +2430,6 @@ const _sfc_main$9 = {
2430
2430
  } else {
2431
2431
  const treeData = [];
2432
2432
  this.inputTempates.forEach((template) => {
2433
- console.log(template, "template");
2434
2433
  const tData = { ...template, id: template.templateId, label: template.templateName };
2435
2434
  tData.children = [];
2436
2435
  if (!template.lanes) {
@@ -2602,7 +2601,7 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
2602
2601
  [_directive_loading, $data.curveConfigLoading]
2603
2602
  ]);
2604
2603
  }
2605
- const RealTimeCurveConfig = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$9], ["__scopeId", "data-v-41fc6892"]]);
2604
+ const RealTimeCurveConfig = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$9], ["__scopeId", "data-v-3338a667"]]);
2606
2605
  const ACTION_TYPE = {
2607
2606
  UPSERT_LINE: "upsertLine",
2608
2607
  DELETE_LINE: "delLine"
@@ -2969,7 +2968,7 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
2969
2968
  ])
2970
2969
  ], 4);
2971
2970
  }
2972
- const LegendItem = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$7], ["__scopeId", "data-v-efba8aa1"]]);
2971
+ const LegendItem = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$7], ["__scopeId", "data-v-6190e06c"]]);
2973
2972
  const _sfc_main$6 = {
2974
2973
  name: "KdLaneContainer",
2975
2974
  provide() {
@@ -3239,7 +3238,9 @@ const _sfc_main$6 = {
3239
3238
  const headerEl = document.getElementById(`lane-header-${lane.laneId}`);
3240
3239
  if (headerEl) {
3241
3240
  const id = String(lane.laneId);
3242
- const newWidth = headerEl.clientWidth;
3241
+ const flexWidth = headerEl.clientWidth;
3242
+ const minWidth = lane.minWidth || 40;
3243
+ const newWidth = Math.max(minWidth, flexWidth);
3243
3244
  const oldWidth = this.laneWidthOverrides[id];
3244
3245
  if (oldWidth !== newWidth) {
3245
3246
  this.setLaneWidthOverride(lane.laneId, newWidth);
@@ -3270,7 +3271,7 @@ const _sfc_main$6 = {
3270
3271
  (l) => l.laneId === this.currentLane.laneId
3271
3272
  );
3272
3273
  if (laneIndex === -1) return;
3273
- const minWidth = 40;
3274
+ const minWidth = lanes[laneIndex].minWidth || 40;
3274
3275
  const getWidth = (lane) => this.getEffectiveLaneWidthPx(lane);
3275
3276
  const currentLane = lanes[laneIndex];
3276
3277
  let currentWidth = getWidth(currentLane);
@@ -3344,6 +3345,9 @@ const _sfc_main$6 = {
3344
3345
  },
3345
3346
  onLaneDragStart() {
3346
3347
  this.isLaneDragging = true;
3348
+ this._laneOrderBeforeDrag = (this.currentTemplate.lanes || []).map(
3349
+ (l) => l.laneId
3350
+ );
3347
3351
  },
3348
3352
  onLineDragEnd() {
3349
3353
  this.syncLinesLaneIdsFromCurrent();
@@ -3357,15 +3361,22 @@ const _sfc_main$6 = {
3357
3361
  },
3358
3362
  onLaneDragEnd() {
3359
3363
  const lanes = this.currentTemplate.lanes || [];
3364
+ const currentOrder = lanes.map((l) => l.laneId);
3365
+ const hasChanged = !this._laneOrderBeforeDrag || this._laneOrderBeforeDrag.length !== currentOrder.length || this._laneOrderBeforeDrag.some((id, i) => id !== currentOrder[i]);
3360
3366
  lanes.forEach((lane, index2) => {
3361
3367
  lane.sort = index2;
3362
3368
  });
3363
3369
  sortLanes(lanes);
3364
- this.notifyTemplateChangeImmediately();
3365
- Promise.all(lanes.map((lane) => this.dragUpdateLane(lane))).then(() => {
3366
- this.setDefaultAndNotify();
3370
+ if (hasChanged) {
3371
+ this.notifyTemplateChangeImmediately();
3372
+ Promise.all(lanes.map((lane) => this.dragUpdateLane(lane))).then(() => {
3373
+ this.setDefaultAndNotify();
3374
+ this.isLaneDragging = false;
3375
+ });
3376
+ } else {
3367
3377
  this.isLaneDragging = false;
3368
- });
3378
+ }
3379
+ this._laneOrderBeforeDrag = null;
3369
3380
  },
3370
3381
  // 拖拽更新曲线
3371
3382
  dragUpdateLine(data) {
@@ -4046,6 +4057,12 @@ const _sfc_main$6 = {
4046
4057
  }
4047
4058
  }
4048
4059
  },
4060
+ laneDragFilter() {
4061
+ if (this.isGeomechanical) {
4062
+ return ".no-drag, .kd-lane-chart-lane-container-echart, .kd-lane-chart-container-draw-area";
4063
+ }
4064
+ return ".no-drag";
4065
+ },
4049
4066
  darwAreaStyle() {
4050
4067
  const headerStyle = this.headerStyle;
4051
4068
  const heightNum = pxToNumber(headerStyle.height);
@@ -4076,7 +4093,7 @@ const _hoisted_6$2 = ["onMousedown"];
4076
4093
  const _hoisted_7$2 = ["id", "lane-id"];
4077
4094
  const _hoisted_8$1 = ["onMousedown"];
4078
4095
  const _hoisted_9$1 = {
4079
- key: 1,
4096
+ key: 0,
4080
4097
  class: "kd-lane-chart-lane-container-echart"
4081
4098
  };
4082
4099
  const _hoisted_10$1 = ["onContextmenu"];
@@ -4140,11 +4157,10 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
4140
4157
  $props.isKdCurveV2 ? (openBlock(), createElementBlock("div", _hoisted_2$5, [
4141
4158
  renderSlot(_ctx.$slots, `slotheader-content-${lane.laneId}`, { lane }, void 0, true)
4142
4159
  ])) : createCommentVNode("", true),
4143
- index2 < $options.fixedLanes.length - 1 || $options.scrollableLanes.length > 0 ? (openBlock(), createElementBlock("div", {
4144
- key: 1,
4160
+ createElementVNode("div", {
4145
4161
  class: "kd-lane-resize-handle kd-lane-resize-handle-right",
4146
4162
  onMousedown: ($event) => $options.startResize($event, lane, "right")
4147
- }, null, 40, _hoisted_3$4)) : createCommentVNode("", true)
4163
+ }, null, 40, _hoisted_3$4)
4148
4164
  ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
4149
4165
  createElementVNode("div", {
4150
4166
  class: normalizeClass(["kd-lane-chart-lane-header", {
@@ -4200,11 +4216,10 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
4200
4216
  $props.isKdCurveV2 ? (openBlock(), createElementBlock("div", _hoisted_5$3, [
4201
4217
  renderSlot(_ctx.$slots, `content-${lane.laneId}`, { lane }, void 0, true)
4202
4218
  ])) : createCommentVNode("", true),
4203
- index2 < $options.fixedLanes.length - 1 || $options.scrollableLanes.length > 0 ? (openBlock(), createElementBlock("div", {
4204
- key: 1,
4219
+ createElementVNode("div", {
4205
4220
  class: "kd-lane-resize-handle kd-lane-resize-handle-right",
4206
4221
  onMousedown: ($event) => $options.startResize($event, lane, "right")
4207
- }, null, 40, _hoisted_6$2)) : createCommentVNode("", true)
4222
+ }, null, 40, _hoisted_6$2)
4208
4223
  ], 64))
4209
4224
  ], 14, _hoisted_1$6);
4210
4225
  }), 128)),
@@ -4219,7 +4234,8 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
4219
4234
  swapThreshold: 0.65,
4220
4235
  group: { name: "laneGroup", pull: false, put: false },
4221
4236
  "item-key": "laneId",
4222
- filter: ".no-drag"
4237
+ filter: $options.laneDragFilter,
4238
+ axis: "x"
4223
4239
  }, {
4224
4240
  default: withCtx(() => [
4225
4241
  (openBlock(true), createElementBlock(Fragment, null, renderList($options.scrollableLanes || [], (lane, index2) => {
@@ -4252,11 +4268,10 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
4252
4268
  }, [
4253
4269
  renderSlot(_ctx.$slots, `lane${lane.laneId}`, { lane }, void 0, true)
4254
4270
  ], 4),
4255
- index2 < $options.scrollableLanes.length - 1 ? (openBlock(), createElementBlock("div", {
4256
- key: 0,
4271
+ createElementVNode("div", {
4257
4272
  class: "kd-lane-resize-handle kd-lane-resize-handle-right",
4258
4273
  onMousedown: ($event) => $options.startResize($event, lane, "right")
4259
- }, null, 40, _hoisted_8$1)) : createCommentVNode("", true),
4274
+ }, null, 40, _hoisted_8$1),
4260
4275
  $props.isKdCurveV2 ? (openBlock(), createElementBlock("div", _hoisted_9$1, [
4261
4276
  renderSlot(_ctx.$slots, `slotheader-content-${lane.laneId}`, { lane }, void 0, true)
4262
4277
  ])) : createCommentVNode("", true)
@@ -4315,17 +4330,16 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
4315
4330
  $props.isKdCurveV2 ? (openBlock(), createElementBlock("div", _hoisted_11$1, [
4316
4331
  renderSlot(_ctx.$slots, `content-${lane.laneId}`, { lane }, void 0, true)
4317
4332
  ])) : createCommentVNode("", true),
4318
- index2 < $options.scrollableLanes.length - 1 ? (openBlock(), createElementBlock("div", {
4319
- key: 1,
4333
+ createElementVNode("div", {
4320
4334
  class: "kd-lane-resize-handle kd-lane-resize-handle-right",
4321
4335
  onMousedown: ($event) => $options.startResize($event, lane, "right")
4322
- }, null, 40, _hoisted_12$1)) : createCommentVNode("", true)
4336
+ }, null, 40, _hoisted_12$1)
4323
4337
  ], 64))
4324
4338
  ], 14, _hoisted_7$2);
4325
4339
  }), 128))
4326
4340
  ]),
4327
4341
  _: 3
4328
- }, 8, ["onStart", "onEnd", "modelValue"])
4342
+ }, 8, ["onStart", "onEnd", "modelValue", "filter"])
4329
4343
  ], 64)) : (openBlock(), createElementBlock("div", _hoisted_13$1, [
4330
4344
  createElementVNode("div", {
4331
4345
  class: normalizeClass(["kd-lane-chart-lane-header", { "kd-lane-chart-lane-header-isKdCurveV2": $props.isKdCurveV2 }]),
@@ -4407,7 +4421,7 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
4407
4421
  }, 8, ["modelValue", "onClose"])
4408
4422
  ], 544);
4409
4423
  }
4410
- const KdLaneContainerComponent = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6], ["__scopeId", "data-v-58d1cc31"]]);
4424
+ const KdLaneContainerComponent = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6], ["__scopeId", "data-v-dcac42f7"]]);
4411
4425
  const SLIDER_GROUP_ID = "depthSliderGroup";
4412
4426
  function pad2(n) {
4413
4427
  return n < 10 ? "0" + n : "" + n;
@@ -6968,6 +6982,41 @@ const _sfc_main$3 = {
6968
6982
  }
6969
6983
  },
6970
6984
  methods: {
6985
+ // 保存 dataZoom 状态,用于 setOption 后恢复
6986
+ _saveDataZoomState() {
6987
+ if (!this.chart || this.chart.isDisposed()) return null;
6988
+ try {
6989
+ const option = this.chart.getOption();
6990
+ if (option && option.dataZoom && option.dataZoom.length > 0) {
6991
+ return option.dataZoom.map((dz) => ({
6992
+ start: dz.start,
6993
+ end: dz.end,
6994
+ startValue: dz.startValue,
6995
+ endValue: dz.endValue
6996
+ }));
6997
+ }
6998
+ } catch (e) {
6999
+ }
7000
+ return null;
7001
+ },
7002
+ _restoreDataZoomState(savedState) {
7003
+ if (!savedState || !this.chart || this.chart.isDisposed()) return;
7004
+ try {
7005
+ const currentOption = this.chart.getOption();
7006
+ if (!currentOption.dataZoom || currentOption.dataZoom.length === 0) return;
7007
+ savedState.forEach((state, i) => {
7008
+ if (i < currentOption.dataZoom.length) {
7009
+ const dz = currentOption.dataZoom[i];
7010
+ if (state.start !== void 0) dz.start = state.start;
7011
+ if (state.end !== void 0) dz.end = state.end;
7012
+ if (state.startValue !== void 0) dz.startValue = state.startValue;
7013
+ if (state.endValue !== void 0) dz.endValue = state.endValue;
7014
+ }
7015
+ });
7016
+ this.chart.setOption({ dataZoom: currentOption.dataZoom });
7017
+ } catch (e) {
7018
+ }
7019
+ },
6971
7020
  // provide an explicit merge option method
6972
7021
  mergeOptions(options, notMerge, lazyUpdate, skipClone) {
6973
7022
  if (this.manualUpdate) {
@@ -6977,7 +7026,11 @@ const _sfc_main$3 = {
6977
7026
  this.init(options);
6978
7027
  } else {
6979
7028
  this._skipWatcher = true;
7029
+ const savedDataZoom = this._saveDataZoomState();
6980
7030
  this.delegateMethod("setOption", this.getOptionsWithTheme(options, skipClone), notMerge, lazyUpdate);
7031
+ if (savedDataZoom) {
7032
+ this._restoreDataZoomState(savedDataZoom);
7033
+ }
6981
7034
  this.$nextTick(() => {
6982
7035
  this._skipWatcher = false;
6983
7036
  });
@@ -7129,7 +7182,11 @@ const _sfc_main$3 = {
7129
7182
  if (!this.chart) {
7130
7183
  this.init(val);
7131
7184
  } else {
7185
+ const savedDataZoom = this._saveDataZoomState();
7132
7186
  this.chart.setOption(this.getOptionsWithTheme(val), val !== oldVal);
7187
+ if (savedDataZoom) {
7188
+ this._restoreDataZoomState(savedDataZoom);
7189
+ }
7133
7190
  if (this.group) {
7134
7191
  this.chart.group = this.group;
7135
7192
  }
@@ -7213,7 +7270,7 @@ const _hoisted_1$3 = { class: "echarts" };
7213
7270
  function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
7214
7271
  return openBlock(), createElementBlock("div", _hoisted_1$3);
7215
7272
  }
7216
- const resizeEcharts = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3], ["__scopeId", "data-v-d8f35894"]]);
7273
+ const resizeEcharts = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3], ["__scopeId", "data-v-137d625e"]]);
7217
7274
  const _sfc_main$2 = {
7218
7275
  name: "LineChartContainer",
7219
7276
  components: {
@@ -7489,12 +7546,6 @@ const _sfc_main$2 = {
7489
7546
  this.scheduleConnectAllCharts = debounce(() => {
7490
7547
  this.connectAllCharts();
7491
7548
  }, 50);
7492
- this.getCssVar = (key) => {
7493
- if (!this.cssVarCache[key]) {
7494
- this.cssVarCache[key] = getCssVariable(key);
7495
- }
7496
- return this.cssVarCache[key];
7497
- };
7498
7549
  },
7499
7550
  mounted() {
7500
7551
  this.showDateTime = Object.prototype.hasOwnProperty.call(
@@ -7749,11 +7800,13 @@ const _sfc_main$2 = {
7749
7800
  if (scaleValues.length === 0) return;
7750
7801
  const minScale = Math.min(...scaleValues);
7751
7802
  const maxScale = Math.max(...scaleValues);
7803
+ const safeCm = this.pxToCm();
7804
+ const safeDepthInterval = this.depthInterval || 1;
7752
7805
  this.minWindowSize = Math.round(
7753
- this.pxToCm() * (+minScale / this.depthInterval)
7806
+ safeCm * (+minScale / safeDepthInterval)
7754
7807
  );
7755
7808
  this.maxWindowSize = Math.round(
7756
- this.pxToCm() * (+maxScale / this.depthInterval)
7809
+ safeCm * (+maxScale / safeDepthInterval)
7757
7810
  );
7758
7811
  this.updateSettings({
7759
7812
  key: "scale",
@@ -7806,11 +7859,12 @@ const _sfc_main$2 = {
7806
7859
  // 将当前页面px转换为cm
7807
7860
  pxToCm() {
7808
7861
  const container = this.$refs.targetDom;
7862
+ if (!container) return 4;
7809
7863
  const rect = container.getBoundingClientRect();
7810
7864
  const headerHeight = this.$refs.chartContainer && this.$refs.chartContainer.getLaneHeightPx() || 0;
7811
7865
  const px = rect.height - headerHeight;
7812
7866
  const cm = px / 25;
7813
- return cm;
7867
+ return cm > 0 ? cm : 4;
7814
7868
  },
7815
7869
  // 获取当前可见数据的x轴范围
7816
7870
  getXAxisRangeByHeader(lineInfo, validData = []) {
@@ -7987,6 +8041,7 @@ const _sfc_main$2 = {
7987
8041
  },
7988
8042
  // 处理鼠标滚轮事件
7989
8043
  handleWheel(e) {
8044
+ if (this.isGeomechanical) return;
7990
8045
  e.preventDefault();
7991
8046
  const dataLength = this.realTimeData && this.realTimeData.length || 0;
7992
8047
  this.wheelDelta = Math.sign(e.deltaY);
@@ -8138,14 +8193,20 @@ const _sfc_main$2 = {
8138
8193
  // 处理工具栏设置变更
8139
8194
  async updateSettings(settings) {
8140
8195
  if (settings.key === "displayType") {
8196
+ cancelAnimationFrame(this.animationId);
8141
8197
  this.toggleTooltip(settings.value == "float");
8142
8198
  }
8143
8199
  if (settings.key === "scale") {
8200
+ cancelAnimationFrame(this.animationId);
8201
+ this.targetStartIndex = this.startIndex;
8144
8202
  this.scaleToDataSize(settings.value);
8203
+ this.targetWindowSize = this.windowSize;
8204
+ this.targetStartIndex = this.startIndex;
8145
8205
  await this.$nextTick();
8146
8206
  this.updateLanesChartOption();
8147
8207
  }
8148
8208
  if (settings.key === "depthRange" || settings.key === "timeRange") {
8209
+ cancelAnimationFrame(this.animationId);
8149
8210
  if (this.realTimeData.length > 0) {
8150
8211
  const axisType = this.formCache.axisType;
8151
8212
  const axisKey = this.currentToolBarConfig.axisTypeList && this.currentToolBarConfig.axisTypeList[axisType];
@@ -8349,7 +8410,7 @@ const _sfc_main$2 = {
8349
8410
  // 获取默认的泳道图表选项
8350
8411
  getDefaultLaneChartOption() {
8351
8412
  const option = {
8352
- backgroundColor: this.getCssVar("--kd-lane-container-item-bg"),
8413
+ backgroundColor: getCssVariable("--kd-lane-container-item-bg"),
8353
8414
  grid: {
8354
8415
  top: 0,
8355
8416
  left: 2,
@@ -8375,7 +8436,7 @@ const _sfc_main$2 = {
8375
8436
  showMinLine: false,
8376
8437
  showMaxLine: false,
8377
8438
  lineStyle: {
8378
- color: this.getCssVar("--kd-lane-container-item-line-color"),
8439
+ color: getCssVariable("--kd-lane-container-item-line-color"),
8379
8440
  type: "dashed"
8380
8441
  }
8381
8442
  },
@@ -8402,7 +8463,7 @@ const _sfc_main$2 = {
8402
8463
  showMinLine: false,
8403
8464
  showMaxLine: false,
8404
8465
  lineStyle: {
8405
- color: this.getCssVar("--kd-lane-container-item-line-color"),
8466
+ color: getCssVariable("--kd-lane-container-item-line-color"),
8406
8467
  type: "dashed"
8407
8468
  }
8408
8469
  },
@@ -8413,7 +8474,7 @@ const _sfc_main$2 = {
8413
8474
  axisLabel: {
8414
8475
  show: false,
8415
8476
  fontSize: 12,
8416
- color: this.getCssVar("--default-text-color")
8477
+ color: getCssVariable("--default-text-color")
8417
8478
  },
8418
8479
  axisTick: {
8419
8480
  show: false
@@ -8428,7 +8489,7 @@ const _sfc_main$2 = {
8428
8489
  type: "inside",
8429
8490
  orient: "vertical",
8430
8491
  filterMode: "none",
8431
- disabled: true
8492
+ disabled: !this.isGeomechanical
8432
8493
  }
8433
8494
  ],
8434
8495
  tooltip: {
@@ -8438,10 +8499,11 @@ const _sfc_main$2 = {
8438
8499
  axisPointer: {
8439
8500
  type: "line",
8440
8501
  axis: "y",
8502
+ z: 999,
8441
8503
  snap: true,
8442
8504
  label: {
8443
- backgroundColor: `${this.getCssVar("--kd-lane-container-border-color")}99`,
8444
- color: `${this.getCssVar("--default-text-color")}`,
8505
+ backgroundColor: `${getCssVariable("--kd-lane-container-border-color")}99`,
8506
+ color: `${getCssVariable("--default-text-color")}`,
8445
8507
  show: true,
8446
8508
  formatter: (params) => {
8447
8509
  var _a;
@@ -8459,10 +8521,10 @@ const _sfc_main$2 = {
8459
8521
  },
8460
8522
  confine: true,
8461
8523
  // appendTo: document.querySelector('.kd-curve-2d-container'),
8462
- backgroundColor: this.getCssVar("--tooltip-bg-color"),
8524
+ backgroundColor: getCssVariable("--tooltip-bg-color"),
8463
8525
  borderWidth: 0,
8464
8526
  textStyle: {
8465
- color: this.getCssVar("--default-text-color")
8527
+ color: getCssVariable("--default-text-color")
8466
8528
  },
8467
8529
  formatter: (series) => {
8468
8530
  var _a;
@@ -8727,7 +8789,7 @@ const _sfc_main$2 = {
8727
8789
  showMinLine: false,
8728
8790
  showMaxLine: false,
8729
8791
  lineStyle: {
8730
- color: this.getCssVar(
8792
+ color: getCssVariable(
8731
8793
  "--kd-lane-container-item-line-color"
8732
8794
  ),
8733
8795
  type: "dashed"
@@ -8738,7 +8800,7 @@ const _sfc_main$2 = {
8738
8800
  axisLabel: {
8739
8801
  show: false,
8740
8802
  fontSize: 12,
8741
- color: this.getCssVar("--default-text-color")
8803
+ color: getCssVariable("--default-text-color")
8742
8804
  },
8743
8805
  axisPointer: { show: hasValidLineData },
8744
8806
  interval: unifiedInterval
@@ -8773,7 +8835,7 @@ const _sfc_main$2 = {
8773
8835
  hideOverlap: true,
8774
8836
  height: 14,
8775
8837
  verticalAlign: "middle",
8776
- color: this.getCssVar("--default-text-color"),
8838
+ color: getCssVariable("--default-text-color"),
8777
8839
  overflow: "truncate",
8778
8840
  rich: {
8779
8841
  center: {
@@ -8846,13 +8908,13 @@ const _sfc_main$2 = {
8846
8908
  )
8847
8909
  };
8848
8910
  }
8849
- const groupSeriesData = this.generateSeriesDataCached(
8911
+ let groupSeriesData = this.generateSeriesDataCached(
8850
8912
  group,
8851
8913
  lineInfo,
8852
8914
  axisKey,
8853
8915
  paramCodeMap
8854
8916
  );
8855
- const groupAllSeriesData = this.generateAllSeriesDataCached(
8917
+ let groupAllSeriesData = this.generateAllSeriesDataCached(
8856
8918
  group,
8857
8919
  lineInfo,
8858
8920
  axisKey,
@@ -8877,7 +8939,7 @@ const _sfc_main$2 = {
8877
8939
  showMaxLine: false,
8878
8940
  showMinLine: false,
8879
8941
  lineStyle: {
8880
- color: this.getCssVar(
8942
+ color: getCssVariable(
8881
8943
  "--kd-lane-container-item-line-color"
8882
8944
  ),
8883
8945
  type: "dashed"
@@ -8929,7 +8991,7 @@ const _sfc_main$2 = {
8929
8991
  this.addAreaStyleToSeries(
8930
8992
  baseSeries,
8931
8993
  lineInfo,
8932
- groupSeriesData,
8994
+ groupAllSeriesData,
8933
8995
  min
8934
8996
  );
8935
8997
  const rangeAreaSeries = this.addRangeAreaToSeries(
@@ -9102,6 +9164,49 @@ const _sfc_main$2 = {
9102
9164
  }
9103
9165
  }
9104
9166
  },
9167
+ /**
9168
+ * LTTB 降采样算法
9169
+ * @param {Array<[number, number]>} data 原始数据 [[x,y], [x,y]]
9170
+ * @param {number} threshold 采样后最大点数(建议 600 ~ 1200)
9171
+ * @returns {Array<[number, number]>} 抽稀后数据
9172
+ */
9173
+ lttb(data, threshold) {
9174
+ if (threshold >= data.length || threshold === 0) {
9175
+ return [...data];
9176
+ }
9177
+ if (threshold === 1) {
9178
+ return [data[0]];
9179
+ }
9180
+ const output = [];
9181
+ const dataLength = data.length;
9182
+ const bucketSize = (dataLength - 2) / (threshold - 2);
9183
+ output.push(data[0]);
9184
+ let prevIndex = 0;
9185
+ for (let i = 0; i < threshold - 2; i++) {
9186
+ const bucketStart = 1 + Math.floor((i + 0) * bucketSize);
9187
+ const bucketEnd = 1 + Math.floor((i + 1) * bucketSize);
9188
+ const nextBucketMidIdx = Math.floor((i + 1.5) * bucketSize);
9189
+ let maxArea = -1;
9190
+ let maxAreaIndex = bucketStart;
9191
+ const pointA = data[prevIndex];
9192
+ const pointC = data[Math.min(nextBucketMidIdx, dataLength - 1)];
9193
+ for (let j = bucketStart; j < bucketEnd; j++) {
9194
+ const pointB = data[j];
9195
+ const area = Math.abs(
9196
+ (pointA[0] - pointC[0]) * (pointB[1] - pointA[1]) - (pointA[0] - pointB[0]) * (pointC[1] - pointA[1])
9197
+ );
9198
+ if (area > maxArea) {
9199
+ maxArea = area;
9200
+ maxAreaIndex = j;
9201
+ }
9202
+ }
9203
+ output.push(data[maxAreaIndex]);
9204
+ prevIndex = maxAreaIndex;
9205
+ }
9206
+ output.push(data[dataLength - 1]);
9207
+ console.log(output, "output");
9208
+ return output;
9209
+ },
9105
9210
  // 生成泳道图表数据
9106
9211
  generateSeriesData(data, lineInfo, axisKey) {
9107
9212
  return data.map((item) => {
@@ -10142,15 +10247,12 @@ const _sfc_main$2 = {
10142
10247
  if (!areaItem.data || areaItem.data.length < 2) continue;
10143
10248
  if (lineInfo.laneId !== this.activeLaneId && areaItem.type === "markArea")
10144
10249
  continue;
10145
- if (areaItem.data[0].timestamp) {
10146
- areaItem.data.sort(
10147
- (a, b) => this.toMillisecondTimestamp(a.timestamp) - this.toMillisecondTimestamp(b.timestamp)
10148
- );
10149
- } else {
10150
- areaItem.data.sort((a, b) => Number(a[axisKey]) - Number(b[axisKey]));
10151
- }
10152
- const startData = areaItem.data[0];
10153
- const endData = areaItem.data[1];
10250
+ const hasTimestamp = areaItem.data[0].timestamp;
10251
+ const sortedData = hasTimestamp ? [...areaItem.data].sort(
10252
+ (a, b) => this.toMillisecondTimestamp(a.timestamp) - this.toMillisecondTimestamp(b.timestamp)
10253
+ ) : [...areaItem.data].sort((a, b) => Number(a[axisKey]) - Number(b[axisKey]));
10254
+ const startData = sortedData[0];
10255
+ const endData = sortedData[1];
10154
10256
  console.log("startData", startData, "endData", endData);
10155
10257
  let startY, endY;
10156
10258
  if (this.formCache.axisType === "depth") {
@@ -10200,6 +10302,8 @@ const _sfc_main$2 = {
10200
10302
  const diff = Number(d[axisKey]) - Number(endDepth);
10201
10303
  if (diff <= 0) {
10202
10304
  closestEndItem = d;
10305
+ } else {
10306
+ break;
10203
10307
  }
10204
10308
  }
10205
10309
  if (closestEndItem) {
@@ -10245,6 +10349,8 @@ const _sfc_main$2 = {
10245
10349
  const diff = this.toMillisecondTimestamp(d[axisKey]) - endTimeMs;
10246
10350
  if (diff < 0) {
10247
10351
  closestEndItem = d;
10352
+ } else {
10353
+ break;
10248
10354
  }
10249
10355
  }
10250
10356
  endY = closestEndItem ? endTimeMs : null;
@@ -10359,13 +10465,15 @@ const _sfc_main$2 = {
10359
10465
  }
10360
10466
  if (seriesData.length > 0) {
10361
10467
  const firstValidPoint = seriesData.find(
10362
- (point) => Number.isFinite(+point[0])
10468
+ (point) => {
10469
+ return Number.isFinite(+point.value[0]);
10470
+ }
10363
10471
  );
10364
10472
  if (firstValidPoint) {
10365
- seriesData.unshift([min, firstValidPoint[1]]);
10473
+ seriesData.unshift([min, firstValidPoint.value[1]]);
10366
10474
  const lastValidPoint = seriesData[seriesData.length - 1];
10367
- if (lastValidPoint && Number.isFinite(+lastValidPoint[0])) {
10368
- seriesData.push([min, lastValidPoint[1]]);
10475
+ if (lastValidPoint && Number.isFinite(+lastValidPoint.value[0])) {
10476
+ seriesData.push([min, lastValidPoint.value[1]]);
10369
10477
  }
10370
10478
  }
10371
10479
  }
@@ -10808,16 +10916,18 @@ const _sfc_main$2 = {
10808
10916
  if (typeof scale == "string") {
10809
10917
  scale = +scale.replace("1:", "") / 100;
10810
10918
  }
10811
- let size = Math.round(this.pxToCm() * (+scale / this.depthInterval));
10919
+ const safeCm = this.pxToCm();
10920
+ const safeDepthInterval = this.depthInterval || 1;
10921
+ let size = Math.round(safeCm * (+scale / safeDepthInterval));
10812
10922
  let maxSize = Math.max(
10813
- Math.round(this.pxToCm() * (1 / this.depthInterval)),
10923
+ Math.round(safeCm * (1 / safeDepthInterval)),
10814
10924
  this.realTimeData.length
10815
10925
  );
10816
10926
  if (size < maxSize) {
10817
10927
  this.windowSize = size;
10818
10928
  } else {
10819
10929
  this.windowSize = maxSize;
10820
- let newsize = Math.round(maxSize / this.pxToCm() * this.depthInterval);
10930
+ let newsize = Math.round(maxSize / safeCm * safeDepthInterval);
10821
10931
  let data = ((_b = (_a = this.currentToolBarConfig) == null ? void 0 : _a.scaleList) == null ? void 0 : _b.map((item) => item.value)) || [];
10822
10932
  this.$emit(
10823
10933
  "updateScale",
@@ -10932,7 +11042,8 @@ const _sfc_main$2 = {
10932
11042
  this.$nextTick(() => {
10933
11043
  this.updateLanesChartOption();
10934
11044
  });
10935
- }
11045
+ },
11046
+ immediate: true
10936
11047
  },
10937
11048
  windowSize: {
10938
11049
  handler(newVal) {
@@ -10943,7 +11054,9 @@ const _sfc_main$2 = {
10943
11054
  }
10944
11055
  if (newVal && this.formCache.axisType == "depth") {
10945
11056
  let data = ((_b = (_a = this.currentToolBarConfig) == null ? void 0 : _a.scaleList) == null ? void 0 : _b.map((item) => item.value)) || [];
10946
- let size = Math.round(newVal * this.depthInterval / this.pxToCm()) < Math.max(...data) ? Math.round(newVal * this.depthInterval / this.pxToCm()) : Math.max(...data);
11057
+ const safeCm = this.pxToCm();
11058
+ const safeDepthInterval = this.depthInterval || 1;
11059
+ let size = Math.round(newVal * safeDepthInterval / safeCm) < Math.max(...data) ? Math.round(newVal * safeDepthInterval / safeCm) : Math.max(...data);
10947
11060
  this.$emit(
10948
11061
  "updateScale",
10949
11062
  data.includes(size) ? size : `1:${size * 100}`
@@ -11301,7 +11414,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
11301
11414
  ])
11302
11415
  ], 512);
11303
11416
  }
11304
- const chartContainer = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__scopeId", "data-v-2b46ef31"]]);
11417
+ const chartContainer = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__scopeId", "data-v-fa130d62"]]);
11305
11418
  const _sfc_main$1 = {
11306
11419
  name: "ParameterPanel",
11307
11420
  props: {