kd-lane-chart-v3 0.1.1 → 0.1.2

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
@@ -7489,12 +7489,6 @@ const _sfc_main$2 = {
7489
7489
  this.scheduleConnectAllCharts = debounce(() => {
7490
7490
  this.connectAllCharts();
7491
7491
  }, 50);
7492
- this.getCssVar = (key) => {
7493
- if (!this.cssVarCache[key]) {
7494
- this.cssVarCache[key] = getCssVariable(key);
7495
- }
7496
- return this.cssVarCache[key];
7497
- };
7498
7492
  },
7499
7493
  mounted() {
7500
7494
  this.showDateTime = Object.prototype.hasOwnProperty.call(
@@ -8349,7 +8343,7 @@ const _sfc_main$2 = {
8349
8343
  // 获取默认的泳道图表选项
8350
8344
  getDefaultLaneChartOption() {
8351
8345
  const option = {
8352
- backgroundColor: this.getCssVar("--kd-lane-container-item-bg"),
8346
+ backgroundColor: getCssVariable("--kd-lane-container-item-bg"),
8353
8347
  grid: {
8354
8348
  top: 0,
8355
8349
  left: 2,
@@ -8375,7 +8369,7 @@ const _sfc_main$2 = {
8375
8369
  showMinLine: false,
8376
8370
  showMaxLine: false,
8377
8371
  lineStyle: {
8378
- color: this.getCssVar("--kd-lane-container-item-line-color"),
8372
+ color: getCssVariable("--kd-lane-container-item-line-color"),
8379
8373
  type: "dashed"
8380
8374
  }
8381
8375
  },
@@ -8402,7 +8396,7 @@ const _sfc_main$2 = {
8402
8396
  showMinLine: false,
8403
8397
  showMaxLine: false,
8404
8398
  lineStyle: {
8405
- color: this.getCssVar("--kd-lane-container-item-line-color"),
8399
+ color: getCssVariable("--kd-lane-container-item-line-color"),
8406
8400
  type: "dashed"
8407
8401
  }
8408
8402
  },
@@ -8413,7 +8407,7 @@ const _sfc_main$2 = {
8413
8407
  axisLabel: {
8414
8408
  show: false,
8415
8409
  fontSize: 12,
8416
- color: this.getCssVar("--default-text-color")
8410
+ color: getCssVariable("--default-text-color")
8417
8411
  },
8418
8412
  axisTick: {
8419
8413
  show: false
@@ -8440,8 +8434,8 @@ const _sfc_main$2 = {
8440
8434
  axis: "y",
8441
8435
  snap: true,
8442
8436
  label: {
8443
- backgroundColor: `${this.getCssVar("--kd-lane-container-border-color")}99`,
8444
- color: `${this.getCssVar("--default-text-color")}`,
8437
+ backgroundColor: `${getCssVariable("--kd-lane-container-border-color")}99`,
8438
+ color: `${getCssVariable("--default-text-color")}`,
8445
8439
  show: true,
8446
8440
  formatter: (params) => {
8447
8441
  var _a;
@@ -8459,10 +8453,10 @@ const _sfc_main$2 = {
8459
8453
  },
8460
8454
  confine: true,
8461
8455
  // appendTo: document.querySelector('.kd-curve-2d-container'),
8462
- backgroundColor: this.getCssVar("--tooltip-bg-color"),
8456
+ backgroundColor: getCssVariable("--tooltip-bg-color"),
8463
8457
  borderWidth: 0,
8464
8458
  textStyle: {
8465
- color: this.getCssVar("--default-text-color")
8459
+ color: getCssVariable("--default-text-color")
8466
8460
  },
8467
8461
  formatter: (series) => {
8468
8462
  var _a;
@@ -8727,7 +8721,7 @@ const _sfc_main$2 = {
8727
8721
  showMinLine: false,
8728
8722
  showMaxLine: false,
8729
8723
  lineStyle: {
8730
- color: this.getCssVar(
8724
+ color: getCssVariable(
8731
8725
  "--kd-lane-container-item-line-color"
8732
8726
  ),
8733
8727
  type: "dashed"
@@ -8738,7 +8732,7 @@ const _sfc_main$2 = {
8738
8732
  axisLabel: {
8739
8733
  show: false,
8740
8734
  fontSize: 12,
8741
- color: this.getCssVar("--default-text-color")
8735
+ color: getCssVariable("--default-text-color")
8742
8736
  },
8743
8737
  axisPointer: { show: hasValidLineData },
8744
8738
  interval: unifiedInterval
@@ -8773,7 +8767,7 @@ const _sfc_main$2 = {
8773
8767
  hideOverlap: true,
8774
8768
  height: 14,
8775
8769
  verticalAlign: "middle",
8776
- color: this.getCssVar("--default-text-color"),
8770
+ color: getCssVariable("--default-text-color"),
8777
8771
  overflow: "truncate",
8778
8772
  rich: {
8779
8773
  center: {
@@ -8846,13 +8840,13 @@ const _sfc_main$2 = {
8846
8840
  )
8847
8841
  };
8848
8842
  }
8849
- const groupSeriesData = this.generateSeriesDataCached(
8843
+ let groupSeriesData = this.generateSeriesDataCached(
8850
8844
  group,
8851
8845
  lineInfo,
8852
8846
  axisKey,
8853
8847
  paramCodeMap
8854
8848
  );
8855
- const groupAllSeriesData = this.generateAllSeriesDataCached(
8849
+ let groupAllSeriesData = this.generateAllSeriesDataCached(
8856
8850
  group,
8857
8851
  lineInfo,
8858
8852
  axisKey,
@@ -8877,7 +8871,7 @@ const _sfc_main$2 = {
8877
8871
  showMaxLine: false,
8878
8872
  showMinLine: false,
8879
8873
  lineStyle: {
8880
- color: this.getCssVar(
8874
+ color: getCssVariable(
8881
8875
  "--kd-lane-container-item-line-color"
8882
8876
  ),
8883
8877
  type: "dashed"
@@ -8929,7 +8923,7 @@ const _sfc_main$2 = {
8929
8923
  this.addAreaStyleToSeries(
8930
8924
  baseSeries,
8931
8925
  lineInfo,
8932
- groupSeriesData,
8926
+ groupAllSeriesData,
8933
8927
  min
8934
8928
  );
8935
8929
  const rangeAreaSeries = this.addRangeAreaToSeries(
@@ -9102,6 +9096,49 @@ const _sfc_main$2 = {
9102
9096
  }
9103
9097
  }
9104
9098
  },
9099
+ /**
9100
+ * LTTB 降采样算法
9101
+ * @param {Array<[number, number]>} data 原始数据 [[x,y], [x,y]]
9102
+ * @param {number} threshold 采样后最大点数(建议 600 ~ 1200)
9103
+ * @returns {Array<[number, number]>} 抽稀后数据
9104
+ */
9105
+ lttb(data, threshold) {
9106
+ if (threshold >= data.length || threshold === 0) {
9107
+ return [...data];
9108
+ }
9109
+ if (threshold === 1) {
9110
+ return [data[0]];
9111
+ }
9112
+ const output = [];
9113
+ const dataLength = data.length;
9114
+ const bucketSize = (dataLength - 2) / (threshold - 2);
9115
+ output.push(data[0]);
9116
+ let prevIndex = 0;
9117
+ for (let i = 0; i < threshold - 2; i++) {
9118
+ const bucketStart = 1 + Math.floor((i + 0) * bucketSize);
9119
+ const bucketEnd = 1 + Math.floor((i + 1) * bucketSize);
9120
+ const nextBucketMidIdx = Math.floor((i + 1.5) * bucketSize);
9121
+ let maxArea = -1;
9122
+ let maxAreaIndex = bucketStart;
9123
+ const pointA = data[prevIndex];
9124
+ const pointC = data[Math.min(nextBucketMidIdx, dataLength - 1)];
9125
+ for (let j = bucketStart; j < bucketEnd; j++) {
9126
+ const pointB = data[j];
9127
+ const area = Math.abs(
9128
+ (pointA[0] - pointC[0]) * (pointB[1] - pointA[1]) - (pointA[0] - pointB[0]) * (pointC[1] - pointA[1])
9129
+ );
9130
+ if (area > maxArea) {
9131
+ maxArea = area;
9132
+ maxAreaIndex = j;
9133
+ }
9134
+ }
9135
+ output.push(data[maxAreaIndex]);
9136
+ prevIndex = maxAreaIndex;
9137
+ }
9138
+ output.push(data[dataLength - 1]);
9139
+ console.log(output, "output");
9140
+ return output;
9141
+ },
9105
9142
  // 生成泳道图表数据
9106
9143
  generateSeriesData(data, lineInfo, axisKey) {
9107
9144
  return data.map((item) => {
@@ -10359,13 +10396,15 @@ const _sfc_main$2 = {
10359
10396
  }
10360
10397
  if (seriesData.length > 0) {
10361
10398
  const firstValidPoint = seriesData.find(
10362
- (point) => Number.isFinite(+point[0])
10399
+ (point) => {
10400
+ return Number.isFinite(+point.value[0]);
10401
+ }
10363
10402
  );
10364
10403
  if (firstValidPoint) {
10365
- seriesData.unshift([min, firstValidPoint[1]]);
10404
+ seriesData.unshift([min, firstValidPoint.value[1]]);
10366
10405
  const lastValidPoint = seriesData[seriesData.length - 1];
10367
- if (lastValidPoint && Number.isFinite(+lastValidPoint[0])) {
10368
- seriesData.push([min, lastValidPoint[1]]);
10406
+ if (lastValidPoint && Number.isFinite(+lastValidPoint.value[0])) {
10407
+ seriesData.push([min, lastValidPoint.value[1]]);
10369
10408
  }
10370
10409
  }
10371
10410
  }
@@ -10932,7 +10971,8 @@ const _sfc_main$2 = {
10932
10971
  this.$nextTick(() => {
10933
10972
  this.updateLanesChartOption();
10934
10973
  });
10935
- }
10974
+ },
10975
+ immediate: true
10936
10976
  },
10937
10977
  windowSize: {
10938
10978
  handler(newVal) {
@@ -11301,7 +11341,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
11301
11341
  ])
11302
11342
  ], 512);
11303
11343
  }
11304
- const chartContainer = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__scopeId", "data-v-2b46ef31"]]);
11344
+ const chartContainer = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__scopeId", "data-v-4fbcd1bb"]]);
11305
11345
  const _sfc_main$1 = {
11306
11346
  name: "ParameterPanel",
11307
11347
  props: {