kd-lane-chart-v3 0.1.8 → 0.1.9

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
@@ -3381,16 +3381,42 @@ function mapGammaLineApiType(lithType, lineRole) {
3381
3381
  return mainType === "grShale" ? "grClean" : "grShale";
3382
3382
  }
3383
3383
  function resolveTrendParamId(type) {
3384
- const t = String(type || "").trim();
3384
+ let t = String(type || "").trim();
3385
+ if (t.startsWith(":")) t = t.slice(1);
3385
3386
  if (t === "grShale" || t === "grClean") return "8137";
3386
3387
  return t;
3387
3388
  }
3389
+ function inferCalcTypeFromSegments(segments) {
3390
+ const segs = segments || [];
3391
+ if (!segs.some((s) => (s.knots || []).length)) return null;
3392
+ const hasMirror = segs.some((s) => {
3393
+ if (s.lithType === "sandstone") return true;
3394
+ return (s.knots || []).some((k) => k.mirrorValue != null && Number.isFinite(Number(k.mirrorValue)));
3395
+ });
3396
+ return hasMirror ? "moxing" : "hand";
3397
+ }
3398
+ function inferTrendSaveMeta(line, segments) {
3399
+ const segs = segments || [];
3400
+ const hasKnots = segs.some((s) => (s.knots || []).length > 0);
3401
+ if (!hasKnots) return { isDouble: false, calcType: void 0 };
3402
+ const inferredCalc = inferCalcTypeFromSegments(segs);
3403
+ const calcType = line && line.calcType || inferredCalc;
3404
+ const hasMirror = inferredCalc === "moxing";
3405
+ const is8137 = line && String(line.paramId) === "8137";
3406
+ const isDouble = isLineDouble(line) || hasMirror || is8137 && !!calcType;
3407
+ return { isDouble: !!isDouble, calcType };
3408
+ }
3388
3409
  function newSegmentId() {
3389
3410
  return `seg_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 6)}`;
3390
3411
  }
3391
3412
  function makeTrendKey(laneId, paramId) {
3392
3413
  return `${laneId}::${paramId}`;
3393
3414
  }
3415
+ function paramIdFromTrendKey(key) {
3416
+ const sep = String(key || "").lastIndexOf("::");
3417
+ if (sep < 0) return String(key || "");
3418
+ return key.slice(sep + 2);
3419
+ }
3394
3420
  function cloneSegments(segments) {
3395
3421
  return (segments || []).map((seg) => {
3396
3422
  const next = {
@@ -3961,15 +3987,24 @@ class TrendLineManager {
3961
3987
  }
3962
3988
  /** 从模板 line.trendSegments 回显;已有 store 的曲线不覆盖,避免编辑中被模板刷新冲掉。8.21 */
3963
3989
  hydrateFromTemplate(template) {
3964
- if (!this._alive()) return;
3990
+ if (!this._alive()) return null;
3965
3991
  const hasEcho = Array.isArray(this.host.lineListData) && this.host.lineListData.length;
3966
3992
  const lanes = template && template.lanes || [];
3967
3993
  const alive = /* @__PURE__ */ new Set();
3994
+ const lanesToRefresh = /* @__PURE__ */ new Set();
3968
3995
  lanes.forEach((lane) => {
3969
3996
  (lane.lines || []).forEach((line) => {
3970
3997
  if (!lane.laneId || !line.paramId) return;
3971
3998
  const key = makeTrendKey(lane.laneId, line.paramId);
3972
3999
  alive.add(key);
4000
+ const bucket = this.store[key];
4001
+ if (bucket && this._hasTrendKnots(bucket.segments)) return;
4002
+ const fromLaneId = this._tryMigrateTrendStore(line.paramId, key);
4003
+ if (fromLaneId) {
4004
+ lanesToRefresh.add(fromLaneId);
4005
+ lanesToRefresh.add(lane.laneId);
4006
+ return;
4007
+ }
3973
4008
  if (this.store[key]) return;
3974
4009
  if (!hasEcho || !line.trendSegments || !line.trendSegments.length) {
3975
4010
  this.store[key] = { segments: [] };
@@ -3979,8 +4014,41 @@ class TrendLineManager {
3979
4014
  });
3980
4015
  });
3981
4016
  Object.keys(this.store).forEach((key) => {
3982
- if (!alive.has(key)) delete this.store[key];
4017
+ if (!alive.has(key)) {
4018
+ const laneId = key.split("::")[0];
4019
+ if (laneId && this._hasTrendKnots(this.store[key] && this.store[key].segments)) {
4020
+ lanesToRefresh.add(laneId);
4021
+ }
4022
+ delete this.store[key];
4023
+ }
3983
4024
  });
4025
+ if (lanesToRefresh.size) {
4026
+ return lanesToRefresh;
4027
+ }
4028
+ return null;
4029
+ }
4030
+ /** 段内是否已有控制点(可画线)。8.26 */
4031
+ _hasTrendKnots(segments) {
4032
+ return (segments || []).some((s) => (s.knots || []).length > 0);
4033
+ }
4034
+ /**
4035
+ * 曲线表头跨泳道拖拽:把旧 laneId::paramId 的 store 迁到新泳道。
4036
+ * @returns {string|null} 迁出方 laneId,无迁移则 null
4037
+ */
4038
+ _tryMigrateTrendStore(paramId, newKey) {
4039
+ const existing = this.store[newKey];
4040
+ if (existing && this._hasTrendKnots(existing.segments)) return null;
4041
+ const pid = String(paramId);
4042
+ const suffix = `::${pid}`;
4043
+ for (const oldKey of Object.keys(this.store)) {
4044
+ if (oldKey === newKey || !oldKey.endsWith(suffix)) continue;
4045
+ const bucket = this.store[oldKey];
4046
+ if (!bucket || !this._hasTrendKnots(bucket.segments)) continue;
4047
+ this.store[newKey] = bucket;
4048
+ if (this.activeKey === oldKey) this.activeKey = newKey;
4049
+ return oldKey.split("::")[0] || null;
4050
+ }
4051
+ return null;
3984
4052
  }
3985
4053
  getChart(laneId) {
3986
4054
  if (!this._alive()) return null;
@@ -4014,7 +4082,9 @@ class TrendLineManager {
4014
4082
  }
4015
4083
  /** 只认当前 isDraw 曲线。8107 和 8011 不在同一泳道,切到 8011 后不能还按 8107 的 activeKey 消费点击。8.21 */
4016
4084
  getTargetByLane(laneId) {
4017
- const targets = this.listDrawableTargets().filter((t) => t.laneId === laneId);
4085
+ const targets = this.listDrawableTargets().filter(
4086
+ (t) => String(t.laneId) === String(laneId)
4087
+ );
4018
4088
  if (!targets.length) return null;
4019
4089
  if (this.activeKey) {
4020
4090
  const active = targets.find((t) => t.key === this.activeKey && t.editable);
@@ -4337,7 +4407,9 @@ class TrendLineManager {
4337
4407
  if (!option || !lane) return option;
4338
4408
  if (!Array.isArray(option.series)) option.series = [];
4339
4409
  option.series = option.series.filter((s) => !this._isTrendSeriesOpt(s));
4340
- const targets = this.listDrawableTargets().filter((t) => t.laneId === lane.laneId);
4410
+ const targets = this.listDrawableTargets().filter(
4411
+ (t) => String(t.laneId) === String(lane.laneId)
4412
+ );
4341
4413
  const added = [];
4342
4414
  targets.forEach((target) => {
4343
4415
  const curve = this._findCurveSeriesInOption(option, target.paramId);
@@ -4369,7 +4441,9 @@ class TrendLineManager {
4369
4441
  const chart = this.getChart(laneId);
4370
4442
  if (!chart) return;
4371
4443
  this._clearLeftoverGraphic(chart);
4372
- const targets = this.listDrawableTargets().filter((t) => t.laneId === laneId);
4444
+ const targets = this.listDrawableTargets().filter(
4445
+ (t) => String(t.laneId) === String(laneId)
4446
+ );
4373
4447
  const next = [];
4374
4448
  targets.forEach((target) => {
4375
4449
  const axis = this._curveAxisOf(chart, target);
@@ -4792,12 +4866,16 @@ class TrendLineManager {
4792
4866
  getTrendLineData(mainId = "demo") {
4793
4867
  const grouped = {};
4794
4868
  const meta = {};
4869
+ const linesByParam = {};
4795
4870
  this.listDrawableTargets().forEach((t) => {
4796
- grouped[t.paramId] = cloneSegments(t.segments);
4797
- meta[t.paramId] = {
4798
- isDouble: isLineDouble(t.line),
4799
- calcType: t.line && t.line.calcType
4800
- };
4871
+ linesByParam[t.paramId] = t.line;
4872
+ });
4873
+ Object.keys(this.store).forEach((key) => {
4874
+ const segments = this.store[key] && this.store[key].segments;
4875
+ if (!this._hasTrendKnots(segments)) return;
4876
+ const paramId = paramIdFromTrendKey(key);
4877
+ grouped[paramId] = cloneSegments(segments);
4878
+ meta[paramId] = inferTrendSaveMeta(linesByParam[paramId], segments);
4801
4879
  });
4802
4880
  return toTrendLineSavePayload(grouped, mainId, meta);
4803
4881
  }
@@ -4816,6 +4894,7 @@ class TrendLineManager {
4816
4894
  /** 把 geosteering 线段数组灌进对应曲线并画出叠加层。8.21 */
4817
4895
  setTrendLineList(lineList, overwrite = true) {
4818
4896
  if (!Array.isArray(lineList) || !lineList.length) {
4897
+ if (!overwrite) return;
4819
4898
  this.resetAllTrendLines();
4820
4899
  return;
4821
4900
  }
@@ -11370,11 +11449,17 @@ const _sfc_main$2 = {
11370
11449
  async templateChange(template) {
11371
11450
  this.currentTemplate = template;
11372
11451
  this.getLatestLineDataByParamCode();
11373
- if (this.trendLineManager) this.trendLineManager.hydrateFromTemplate(template);
11374
- this.applyLineListData();
11452
+ let migratedLanes = null;
11453
+ if (this.trendLineManager) {
11454
+ migratedLanes = this.trendLineManager.hydrateFromTemplate(template);
11455
+ }
11456
+ if ((this.lineListData || []).length) this.applyLineListData();
11375
11457
  await this.$nextTick();
11376
11458
  if (this._isUnmounted) return;
11377
- this.updateLanesChartOption();
11459
+ await this.updateLanesChartOption();
11460
+ if (this.trendLineManager && migratedLanes && migratedLanes.size) {
11461
+ migratedLanes.forEach((laneId) => this.trendLineManager._flushLane(laneId));
11462
+ }
11378
11463
  },
11379
11464
  // 线段变化
11380
11465
  async lineChange() {
@@ -11535,6 +11620,7 @@ const _sfc_main$2 = {
11535
11620
  option.yAxis = [{}];
11536
11621
  }
11537
11622
  const cachedOption = markRaw(option);
11623
+ if (this.trendLineManager) cachedOption.__kdTrendSynced = true;
11538
11624
  if (index2 != -1) {
11539
11625
  this.allOptions.splice(index2, 1, { lineId, option: cachedOption });
11540
11626
  } else {
@@ -15631,7 +15717,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
15631
15717
  ])
15632
15718
  ], 544);
15633
15719
  }
15634
- const chartContainer = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__scopeId", "data-v-9a816c60"]]);
15720
+ const chartContainer = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__scopeId", "data-v-ec0aa0bf"]]);
15635
15721
  const _sfc_main$1 = {
15636
15722
  name: "ParameterPanel",
15637
15723
  props: {