kd-lane-chart-v3 0.1.22 → 0.1.23

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
@@ -13939,14 +13939,67 @@ const _sfc_main$2 = /* @__PURE__ */ Object.assign({
13939
13939
  }
13940
13940
  }
13941
13941
  }
13942
+ function restoreCoveredAxisTicks() {
13943
+ const covered = proxy._hoverCoveredTicks || [];
13944
+ for (let i = 0; i < covered.length; i++) {
13945
+ if (covered[i]) covered[i].style.visibility = "";
13946
+ }
13947
+ proxy._hoverCoveredTicks = [];
13948
+ }
13949
+ function hideLaneCrosshairSegments() {
13950
+ restoreCoveredAxisTicks();
13951
+ const pool = proxy._laneCrosshairEls || [];
13952
+ for (let i = 0; i < pool.length; i++) {
13953
+ if (pool[i]) pool[i].style.display = "none";
13954
+ }
13955
+ }
13942
13956
  function updateCrosshairLine(sourceChart, offsetY) {
13943
- const wrap = proxy.$refs.chartAreaWrap;
13944
- const el = proxy.$refs.crosshairLine;
13945
- const chartDom = sourceChart.getDom();
13946
- if (!wrap || !el || !chartDom) return;
13947
- const top = chartDom.getBoundingClientRect().top - wrap.getBoundingClientRect().top + offsetY;
13948
- el.style.transform = `translate3d(0, ${top}px, 0)`;
13949
- if (!proxy.crosshairVisible) proxy.crosshairVisible = true;
13957
+ const chartDom = sourceChart && sourceChart.getDom && sourceChart.getDom();
13958
+ if (!chartDom) return;
13959
+ proxy.crosshairVisible = false;
13960
+ restoreCoveredAxisTicks();
13961
+ const sourceTop = chartDom.getBoundingClientRect().top;
13962
+ if (!proxy._laneCrosshairEls) proxy._laneCrosshairEls = [];
13963
+ const pool = proxy._laneCrosshairEls;
13964
+ const charts = proxy.getConnectedCharts();
13965
+ let i = 0;
13966
+ for (let c = 0; c < charts.length; c++) {
13967
+ const chart = charts[c];
13968
+ if (!chart || chart.isDisposed()) continue;
13969
+ const dom = chart.getDom();
13970
+ if (!dom) continue;
13971
+ const localY = offsetY + sourceTop - dom.getBoundingClientRect().top;
13972
+ let seg = pool[i];
13973
+ if (!seg) {
13974
+ seg = document.createElement("div");
13975
+ seg.className = "kd-lane-crosshair-seg";
13976
+ const depth = document.createElement("span");
13977
+ depth.className = "kd-lane-crosshair-seg__depth";
13978
+ seg.appendChild(depth);
13979
+ pool[i] = seg;
13980
+ }
13981
+ if (seg.parentElement !== dom) dom.appendChild(seg);
13982
+ let depthEl = seg.querySelector(".kd-lane-crosshair-seg__depth");
13983
+ if (!depthEl) {
13984
+ depthEl = document.createElement("span");
13985
+ depthEl.className = "kd-lane-crosshair-seg__depth";
13986
+ seg.appendChild(depthEl);
13987
+ }
13988
+ const depthText = proxy._lastTooltipAxisLabel || "";
13989
+ const lane = proxy.findLaneById(proxy.findLaneIdByChart(chart));
13990
+ const isAxisLane = proxy.isDepthOrTimeLane(lane);
13991
+ if (depthEl) {
13992
+ depthEl.textContent = isAxisLane ? "" : depthText;
13993
+ depthEl.classList.remove("is-axis");
13994
+ depthEl.style.display = !isAxisLane && depthText ? "" : "none";
13995
+ }
13996
+ seg.style.display = "block";
13997
+ seg.style.transform = `translate3d(0, ${localY}px, 0)`;
13998
+ i++;
13999
+ }
14000
+ for (let j = i; j < pool.length; j++) {
14001
+ pool[j].style.display = "none";
14002
+ }
13950
14003
  }
13951
14004
  function schedulePointerSync(chart, x, y, clientY) {
13952
14005
  proxy.pointerInChartArea = true;
@@ -13958,11 +14011,14 @@ const _sfc_main$2 = /* @__PURE__ */ Object.assign({
13958
14011
  const hit = proxy.getYValueFromChart(sourceChart, offsetX, offsetY);
13959
14012
  if (!hit) {
13960
14013
  proxy.crosshairVisible = false;
14014
+ hideLaneCrosshairSegments();
13961
14015
  return;
13962
14016
  }
13963
14017
  proxy._lastTooltipY = hit.yValue;
13964
14018
  proxy._lastTooltipOffsetY = offsetY;
13965
14019
  proxy._lastTooltipGridIndex = hit.gridIndex;
14020
+ const row = proxy.findRowByAxisValue(hit.yValue);
14021
+ proxy._lastTooltipAxisLabel = proxy.formatAxisPointerYLabel(hit.yValue, row);
13966
14022
  proxy.updateCrosshairLine(sourceChart, offsetY);
13967
14023
  proxy.showSyncedLaneTooltips(hit.yValue, offsetY, hit.gridIndex);
13968
14024
  }
@@ -14287,6 +14343,7 @@ const _sfc_main$2 = /* @__PURE__ */ Object.assign({
14287
14343
  proxy._lastTipKey = /* @__PURE__ */ new WeakMap();
14288
14344
  proxy._lastAxisPx = /* @__PURE__ */ new WeakMap();
14289
14345
  proxy.crosshairVisible = false;
14346
+ hideLaneCrosshairSegments();
14290
14347
  if (proxy.formCache.displayType === "header") {
14291
14348
  proxy.headerData = {};
14292
14349
  }
@@ -16566,14 +16623,16 @@ const _sfc_main$2 = /* @__PURE__ */ Object.assign({
16566
16623
  }
16567
16624
  function buildSyncedAxisPointer(show) {
16568
16625
  return {
16569
- show: !!show,
16626
+ show: true,
16570
16627
  snap: false,
16571
16628
  type: "line",
16572
16629
  triggerTooltip: false,
16573
- z: 999,
16630
+ // 趋势线 graphic 的 z 是 9999,横线再低会被盖住,有的道看起来没有位置线
16631
+ z: 10001,
16574
16632
  animation: false,
16575
16633
  label: {
16576
- show: !!show,
16634
+ // 画布边缘的轴标签会被泳道裁掉,深度改由每道十字线上的文字显示
16635
+ show: false,
16577
16636
  backgroundColor: `${getCssVariable("--kd-lane-container-border-color")}99`,
16578
16637
  color: `${getCssVariable("--default-text-color")}`,
16579
16638
  formatter: () => proxy._lastTooltipAxisLabel || ""
@@ -16647,7 +16706,7 @@ const _sfc_main$2 = /* @__PURE__ */ Object.assign({
16647
16706
  axisTick: {
16648
16707
  show: false
16649
16708
  },
16650
- axisPointer: buildSyncedAxisPointer(true)
16709
+ axisPointer: buildSyncedAxisPointer()
16651
16710
  }
16652
16711
  ],
16653
16712
  dataZoom: [proxy.buildInsideDataZoom()],
@@ -16896,7 +16955,7 @@ const _sfc_main$2 = /* @__PURE__ */ Object.assign({
16896
16955
  fontSize: 12,
16897
16956
  color: getCssVariable("--default-text-color")
16898
16957
  },
16899
- axisPointer: buildSyncedAxisPointer(hasValidLineData)
16958
+ axisPointer: buildSyncedAxisPointer(true)
16900
16959
  });
16901
16960
  if (proxy.formCache.axisType === "depth") {
16902
16961
  applyDepthYAxisInterval(
@@ -20688,7 +20747,7 @@ const _sfc_main$2 = /* @__PURE__ */ Object.assign({
20688
20747
  };
20689
20748
  }
20690
20749
  });
20691
- const LineChartContainer = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-a716c99b"]]);
20750
+ const LineChartContainer = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-af25fe67"]]);
20692
20751
  const _hoisted_1$1 = ["title"];
20693
20752
  const _hoisted_2$1 = ["title"];
20694
20753
  const _sfc_main$1 = /* @__PURE__ */ Object.assign({