kd-lane-chart-v3 0.1.13 → 0.1.15

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/README.md CHANGED
@@ -1,175 +1,704 @@
1
- # kd-lane-chart
1
+ # kd-lane-chart-v3(Vue 3)使用文档
2
2
 
3
- 泳道图(KdLaneContainer)+ 实时曲线(frameLayout)Vue 2 组件包。
3
+ 面向**第一次接入**的开发者:从安装、跑通演示,到配置模板、灌数据、监听事件、调用 ref 方法,以及常见问题。
4
4
 
5
- > **注意:** 旧包 `kd-lane-container` 和 `kd-curve-v2` 已不再推荐使用,请迁移至此统一包。
5
+ | | 说明 |
6
+ |---|---|
7
+ | npm 包名 | **`kd-lane-chart-v3`**(当前约 `0.1.13`) |
8
+ | 框架 | Vue **^3.5** |
9
+ | UI | Element Plus + `@element-plus/icons-vue` |
10
+ | 演示工程 | 本目录 `kd-curve-v3`(Vite) |
11
+ | 发布产物 | `kd-curve-v3/publish/`(含 `index.d.ts`) |
12
+ | 仓库总览 | 仓库根目录 `使用文档.md`(v2/v3 对照) |
13
+
14
+ > 请勿安装 Vue 2 包 `kd-lane-chart` 到 Vue 3 工程。本目录旧版 USAGE 若仍写 Vue 2,以**本文**为准。
15
+
16
+ 与 Vue 2 版(`kd-lane-chart`)功能对齐,差异主要在:框架 API、UI 库、插槽写法、拖拽库(`vue-draggable-plus`)。
17
+
18
+ 专题手册(路径与 v2 相同,相对本包 `src`):
19
+
20
+ | 专题 | 路径 |
21
+ |---|---|
22
+ | 趋势线 | `src/components/kdCurveV2/trend-line/趋势线使用手册.md` |
23
+ | 对数轴 | `src/components/kdCurveV2/log-axis/对数轴使用手册.md` |
24
+ | 加载/内存 | `src/components/kdCurveV2/perf/加载优化文档.md` |
25
+ | 架构速览 | `CODE_WIKI.md` |
6
26
 
7
27
  ---
8
28
 
9
- ## 安装
29
+ ## 目录
30
+
31
+ 1. [它是什么 / 能做什么](#1-它是什么--能做什么)
32
+ 2. [环境与安装](#2-环境与安装)
33
+ 3. [本地跑演示](#3-本地跑演示)
34
+ 4. [最小接入(5 分钟)](#4-最小接入5-分钟)
35
+ 5. [页面必须满足的条件](#5-页面必须满足的条件)
36
+ 6. [布局面板说明](#6-布局面板说明)
37
+ 7. [Props 一览](#7-props-一览)
38
+ 8. [depthConfig / timeConfig 详解](#8-depthconfig--timeconfig-详解)
39
+ 9. [曲线数据 curveDatas](#9-曲线数据-curvedatas)
40
+ 10. [工具栏 toolBarConfig](#10-工具栏-toolbarconfig)
41
+ 11. [插槽(Vue 3 动态名)](#11-插槽vue-3-动态名)
42
+ 12. [事件](#12-事件)
43
+ 13. [ref 方法(重点)](#13-ref-方法重点)
44
+ 14. [强制更新配置 forceUpdateCurveConfig](#14-强制更新配置-forceupdatecurveconfig)
45
+ 15. [预警 / Tooltip / 主题](#15-预警--tooltip--主题)
46
+ 16. [交互模式与轴标签](#16-交互模式与轴标签)
47
+ 17. [单独使用 KdLaneContainer](#17-单独使用-kdlanecontainer)
48
+ 18. [多语言](#18-多语言)
49
+ 19. [Vue 2 → Vue 3 迁移注意](#19-vue-2--vue-3-迁移注意)
50
+ 20. [接入检查清单](#20-接入检查清单)
51
+ 21. [常见问题](#21-常见问题)
10
52
 
11
- ```bash
12
- npm install kd-lane-chart
13
- ```
53
+ ---
14
54
 
15
- ### 依赖
55
+ ## 1. 它是什么 / 能做什么
16
56
 
17
- | 依赖 | 版本 |
57
+ `kd-lane-chart-v3` 提供:
58
+
59
+ | 组件 | 用途 |
18
60
  |---|---|
19
- | vue | ^2.6.0 |
20
- | element-ui | ^2.15.14 |
21
- | echarts | * |
22
- | vuedraggable | ^2.24.3 |
23
- | v-click-outside | ^2.1.3 |
24
- | resize-detector | ^0.3.0 |
25
- | lodash-es | ^4.18.1 |
61
+ | **`FrameLayout` / `frameLayout`** | 业务主入口:参数栏 + 井深时间小图 + 泳道曲线 + 工具栏 |
62
+ | **`KdLaneContainer`** | 泳道图本体(也可单独用) |
63
+
64
+ 能力与 Vue 2 包对齐:实时/历史曲线、井深/时间轴、比例尺、预警、趋势线、自定义插槽、模板编辑、IndexedDB 本地模板、配置回传与强制覆盖等。
65
+
66
+ 数据流:
67
+
68
+ ```
69
+ 业务页
70
+ ├─ depthConfig / timeConfig → 模板 → IndexedDB(type: local)
71
+ ├─ curveDatas → 测点 replace / append
72
+ ├─ toolBarConfig.form → 轴类型、比例尺…
73
+ └─ ref / 事件 → getCurrentConfig、forceUpdateCurveConfig…
74
+ ```
26
75
 
27
76
  ---
28
77
 
29
- ## 快速开始
78
+ ## 2. 环境与安装
79
+
80
+ ### 2.1 依赖要求(peer)
81
+
82
+ | 依赖 | 建议版本 |
83
+ |---|---|
84
+ | `vue` | `^3.5.0` |
85
+ | `element-plus` | `^2.9.0` |
86
+ | `@element-plus/icons-vue` | `^2.3.1` |
87
+ | `echarts` | `>=5.0.0` |
88
+ | `vue-draggable-plus` | `^0.6.0` |
89
+ | `v3-click-outside` | `^1.0.2` |
90
+ | `resize-detector` | `^0.3.0` |
91
+ | `lodash-es` | `^4.18.1` |
92
+
93
+ 业务工程需自行注册 Element Plus(及图标),并引入样式:
30
94
 
31
95
  ```js
32
- import Vue from "vue";
33
- import { KdLaneContainer, frameLayout } from "kd-lane-chart";
96
+ import ElementPlus from "element-plus";
97
+ import "element-plus/dist/index.css";
98
+ app.use(ElementPlus);
99
+ ```
100
+
101
+ ### 2.2 从 npm 安装
34
102
 
35
- // 全局注册(也可按需单独注册)
36
- Vue.use(KdLaneContainer);
37
- Vue.use(frameLayout);
103
+ ```bash
104
+ npm install kd-lane-chart-v3
105
+ # 或
106
+ pnpm add kd-lane-chart-v3
38
107
  ```
39
108
 
40
- 或在组件内局部使用:
109
+ ### 2.3 本仓库 monorepo
110
+
111
+ ```bash
112
+ # 仓库根
113
+ pnpm install
114
+ pnpm build:v3
115
+
116
+ # test-v3 示例:"kd-lane-chart-v3": "workspace:*"
117
+ ```
118
+
119
+ 本地 link:
120
+
121
+ ```bash
122
+ cd kd-curve-v3/publish
123
+ pnpm run link
124
+ ```
125
+
126
+ ### 2.4 注册组件(Vue 3)
41
127
 
42
128
  ```js
43
- import { KdLaneContainer, frameLayout } from "kd-lane-chart";
129
+ import { createApp } from "vue";
130
+ import ElementPlus from "element-plus";
131
+ import "element-plus/dist/index.css";
132
+ import {
133
+ KdLaneContainer,
134
+ FrameLayout,
135
+ setCurrentLocale,
136
+ installKdI18n,
137
+ } from "kd-lane-chart-v3";
138
+ import App from "./App.vue";
139
+
140
+ const app = createApp(App);
141
+ app.use(ElementPlus);
142
+ app.use(KdLaneContainer);
143
+ app.use(FrameLayout); // 注册 FrameLayout + frameLayout,并会 installKdI18n
144
+ // 或显式:installKdI18n(app);
145
+
146
+ setCurrentLocale("zh-CN");
147
+ app.mount("#app");
148
+ ```
44
149
 
45
- export default {
46
- components: {
47
- KdLaneContainer,
48
- frameLayout,
49
- },
50
- };
150
+ 局部注册(`<script setup>`):
151
+
152
+ ```vue
153
+ <script setup>
154
+ import { FrameLayout, KdLaneContainer } from "kd-lane-chart-v3";
155
+ </script>
156
+
157
+ <template>
158
+ <FrameLayout ref="frameLayoutRef" /* ... */ />
159
+ </template>
51
160
  ```
52
161
 
162
+ TypeScript:包提供 `index.d.ts`,从 `kd-lane-chart-v3` 直接 import 即可。
163
+
164
+ ### 2.5 源码调试
165
+
166
+ 可直接引用 `src/components/kdCurveV2/frame-layout/index.vue`,注意 Vite 别名与 peer 依赖齐全。
167
+
53
168
  ---
54
169
 
55
- ## KdLaneContainer(泳道图)
170
+ ## 3. 本地跑演示
171
+
172
+ ```bash
173
+ cd kd-curve-v3
174
+ pnpm install
175
+ pnpm serve
176
+ # 等价:pnpm dev
177
+ ```
56
178
 
57
- 泳道图组件,用于展示钻井相关的车道数据。
179
+ - 默认:`http://127.0.0.1:8888/`(`vite.config.js`)
180
+ - 端口占用时 Vite 可能换端口,以终端为准
58
181
 
59
- ### 基本用法
182
+ 演示页 `src/App.vue` 仅作接口参考,勿整页拷贝进生产。
183
+
184
+ 构建发布包:
185
+
186
+ ```bash
187
+ # 仓库根
188
+ pnpm build:v3
189
+ ```
190
+
191
+ ---
192
+
193
+ ## 4. 最小接入(5 分钟)
60
194
 
61
195
  ```vue
62
196
  <template>
63
- <kd-lane-container
64
- :config="config"
65
- :datas="datas"
66
- theme-name="dark"
67
- />
197
+ <div class="page" data-theme="dark">
198
+ <FrameLayout
199
+ ref="frameLayoutRef"
200
+ theme-name="dark"
201
+ :depth-config="depthConfig"
202
+ :time-config="timeConfig"
203
+ :curve-datas="curveDatas"
204
+ :tool-bar-config="toolBarConfig"
205
+ @template-change="onTemplateChange"
206
+ @update-settings="onUpdateSettings"
207
+ @config-change="onConfigChange"
208
+ />
209
+ </div>
68
210
  </template>
69
211
 
70
- <script>
71
- export default {
72
- data() {
73
- return {
74
- config: { /* 泳道图配置 */ },
75
- datas: { /* 数据 */ },
76
- };
212
+ <script setup>
213
+ import { onMounted, reactive, ref } from "vue";
214
+ import { FrameLayout, setCurrentLocale } from "kd-lane-chart-v3";
215
+
216
+ setCurrentLocale("zh-CN");
217
+
218
+ const frameLayoutRef = ref(null);
219
+
220
+ const depthConfig = reactive({
221
+ type: "local",
222
+ caseId: "my-well-depth",
223
+ versionCode: 1,
224
+ dataSource: {
225
+ templates: [
226
+ {
227
+ templateName: "默认",
228
+ isPublic: "1",
229
+ createUser: "SYSTEM_USER",
230
+ lanes: [
231
+ {
232
+ laneName: "井深",
233
+ laneKey: "wellDepth",
234
+ canScroll: false,
235
+ canDrag: false,
236
+ width: 60,
237
+ sort: 0,
238
+ lines: [],
239
+ },
240
+ {
241
+ laneName: "大钩负荷",
242
+ sort: 1,
243
+ width: 120,
244
+ lines: [
245
+ {
246
+ paramId: "8010",
247
+ lineSort: 1,
248
+ min: 0,
249
+ max: 8000,
250
+ lineSize: "2",
251
+ lineType: "solid",
252
+ isUsed: "1",
253
+ lineColor: "#3DE375",
254
+ },
255
+ ],
256
+ },
257
+ ],
258
+ },
259
+ ],
260
+ params: [
261
+ { paramId: "wellDepth", paramName: "井深", paramUnit: "m" },
262
+ { paramId: "8010", paramName: "大钩负荷", paramUnit: "kN" },
263
+ ],
264
+ },
265
+ });
266
+
267
+ const timeConfig = reactive({
268
+ type: "local",
269
+ caseId: "my-well-time",
270
+ versionCode: 1,
271
+ dataSource: { templates: [], params: [] },
272
+ });
273
+
274
+ const toolBarConfig = reactive({
275
+ show: true,
276
+ axisTypeList: { depth: "wellDepth", time: "timestamp" },
277
+ form: {
278
+ axisType: "depth",
279
+ dataType: "history",
280
+ displayType: "float",
281
+ scale: 5,
77
282
  },
78
- };
283
+ });
284
+
285
+ const curveDatas = ref({
286
+ type: "replace",
287
+ data: [
288
+ { wellDepth: 1000, timestamp: Date.now(), "8010": 1200 },
289
+ { wellDepth: 1001, timestamp: Date.now() + 1000, "8010": 1250 },
290
+ ],
291
+ });
292
+
293
+ onMounted(() => {
294
+ document.body.setAttribute("data-theme", "dark");
295
+ });
296
+
297
+ function onTemplateChange() {}
298
+ function onUpdateSettings({ key, value }) {
299
+ console.log("settings", key, value);
300
+ }
301
+ function onConfigChange({ axisType, config, reason }) {
302
+ if (axisType === "time") {
303
+ timeConfig.dataSource = config.dataSource;
304
+ if (config.versionCode != null) timeConfig.versionCode = config.versionCode;
305
+ } else {
306
+ depthConfig.dataSource = config.dataSource;
307
+ if (config.versionCode != null) depthConfig.versionCode = config.versionCode;
308
+ }
309
+ console.log("config-change", reason, axisType);
310
+ }
311
+
312
+ // 强制更新示例
313
+ async function forceWrite() {
314
+ await frameLayoutRef.value.forceUpdateCurveConfig();
315
+ }
79
316
  </script>
317
+
318
+ <style>
319
+ .page {
320
+ height: 100vh;
321
+ width: 100%;
322
+ }
323
+ </style>
80
324
  ```
81
325
 
82
- ### Props
326
+ ---
327
+
328
+ ## 5. 页面必须满足的条件
329
+
330
+ 1. **外层明确高度**(`100vh` 或 flex 子项撑满)。
331
+ 2. **`themeName` 与 `document.body` 的 `data-theme` 一致**(`white` / `dark` / `gray`)。
332
+ 3. 先 **`replace`** 再按需 **`append`**。
333
+ 4. **`axisTypeList` 字段 = 数据行键 = 轴列 `laneKey`**。
334
+ 5. **`paramId` = 数据行字段**;缺测用 **`null`**。
335
+ 6. 模板结构变更:**`versionCode++`**,或调用 **`forceUpdateCurveConfig`**。
336
+
337
+ ---
338
+
339
+ ## 6. 布局面板说明
340
+
341
+ | 面板 | 内容 | 开关 |
342
+ |---|---|---|
343
+ | 左 1 | 参数列表 | `parameterPanelConfig.show` |
344
+ | 左 2 | 井深-钻头-时间小图 | `WellBitDepthTimePlotConfig.show` |
345
+ | 中 3 | 主曲线 | 配置有效即显示 |
346
+ | 右 4 | 工具栏 | `toolBarConfig === false` 可隐藏 |
347
+
348
+ `formCache` 是 FrameLayout **内部状态**,不是 prop;由 `toolBarConfig.form` 初始化。
349
+
350
+ ---
351
+
352
+ ## 7. Props 一览
353
+
354
+ 与 Vue 2 版基本相同,另多:
83
355
 
84
356
  | 参数 | 类型 | 说明 |
85
357
  |---|---|---|
86
- | config | Object | 泳道图配置 |
87
- | datas | Object | 数据 |
88
- | themeName | String | 主题:`white` / `dark` / `gray` |
358
+ | `canClickSelectLane` | Boolean | 地应力下是否允许点选泳道红框(常与 `isGeomechanical` 联用) |
359
+
360
+ 其余常用:
361
+
362
+ | 参数 | 说明 |
363
+ |---|---|
364
+ | `depthConfig` / `timeConfig` | 模板配置 |
365
+ | `curveDatas` | `{ type, data }` |
366
+ | `themeName` | `white` / `dark` / `gray` |
367
+ | `toolBarConfig` | 工具栏或 `false` |
368
+ | `parameterPanelConfig` | 左侧参数 |
369
+ | `WellBitDepthTimePlotConfig` | 左侧小图 |
370
+ | `headerStyle` | 表头样式 |
371
+ | `headerSlotName` / `contentSlotName` | 插槽登记 |
372
+ | `warningData` / `warningLabelConfig` / `warningAreaData` | 预警 |
373
+ | `tooltipFormatter` | 返回 **HTML 字符串** |
374
+ | `lineListData` | 趋势线回显 |
375
+ | `isGeomechanical` | 地应力模式 |
376
+ | `showContextMenuStatus` | 右键开关 |
377
+ | `customMenuList` | 扩展菜单 |
378
+
379
+ ---
380
+
381
+ ## 8. depthConfig / timeConfig 详解
382
+
383
+ ```js
384
+ {
385
+ type: "local",
386
+ caseId: "depth", // 必填,存储隔离
387
+ versionCode: 1, // 结构变更必须递增
388
+ dataSource: {
389
+ templates: [
390
+ {
391
+ templateName: "默认",
392
+ lanes: [
393
+ { laneName: "井深", laneKey: "wellDepth", canScroll: false, lines: [] },
394
+ {
395
+ laneName: "曲线道",
396
+ lines: [
397
+ { paramId: "8010", min: 0, max: 8000, lineType: "solid", isUsed: "1", lineColor: "#3DE375" },
398
+ ],
399
+ },
400
+ ],
401
+ },
402
+ ],
403
+ params: [
404
+ { paramId: "wellDepth", paramName: "井深", paramUnit: "m" },
405
+ { paramId: "8010", paramName: "大钩负荷", paramUnit: "kN" },
406
+ ],
407
+ },
408
+ }
409
+ ```
410
+
411
+ 泳道 / 曲线字段含义与 Vue 2 文档一致(`laneKey`、`contentKey`、`isLogScale`、`templateRangeSaved` 等)。
412
+ `type: "local"` 使用 IndexedDB;其它类型走自定义 Strategy。
413
+
414
+ ---
415
+
416
+ ## 9. 曲线数据 curveDatas
417
+
418
+ ```js
419
+ curveDatas.value = { type: "replace", data: rows };
420
+ curveDatas.value = { type: "append", data: row };
421
+ ```
422
+
423
+ 行示例:
424
+
425
+ ```js
426
+ { wellDepth: 1000, timestamp: 1709019984000, "8010": 1200, "8018": null }
427
+ ```
428
+
429
+ 切轴 / 切实时历史:在 `@update-settings` 里 `replace` 对应数据。
430
+ 触顶触底:监听 `@chart-scroll` 补数。
89
431
 
90
432
  ---
91
433
 
92
- ## frameLayout(实时曲线)
434
+ ## 10. 工具栏 toolBarConfig
93
435
 
94
- 实时曲线图表容器,支持井深/时间两种曲线类型、实时/历史数据、多主题、滚动加载等。
436
+ ```js
437
+ toolBarConfig: {
438
+ show: true,
439
+ axisTypeList: { depth: "wellDepth", time: "timestamp" },
440
+ scaleList: [
441
+ { label: "1:100", value: 1 },
442
+ { label: "1:500", value: 5 },
443
+ ],
444
+ form: {
445
+ axisType: "depth",
446
+ dataType: "history",
447
+ displayType: "float",
448
+ scale: 5,
449
+ showLogAxis: true,
450
+ },
451
+ }
452
+ ```
453
+
454
+ 未传的按钮/列表项走组件默认。
455
+
456
+ ---
95
457
 
96
- ### 基本用法
458
+ ## 11. 插槽(Vue 3 动态名)
459
+
460
+ Vue 3 **不要**再用 `:slot=`,请用 `v-slot:[name]`,且 `v-for` 带 `:key`:
97
461
 
98
462
  ```vue
99
- <template>
100
- <frame-layout
101
- ref="frameLayout"
102
- :depthConfig="depthConfig"
103
- :timeConfig="timeConfig"
104
- :curveDatas="curveDatas"
105
- :themeName="themeName"
106
- :toolBarConfig="toolBarConfig"
107
- :parameterPanelConfig="parameterPanelConfig"
108
- :WellBitDepthTimePlotConfig="WellBitDepthTimePlotConfig"
109
- :warningData="warningData"
110
- @template-change="onTemplateChange"
111
- @line-change="onLineChange"
112
- @chart-scroll="onChartScroll"
113
- @updateSettings="onUpdateSettings"
114
- @visibleDataChange="onVisibleDataChange"
115
- @dialogFunction="onDialog"
116
- @refresh="onRefresh"
117
- >
118
- <template v-for="lane in headerSlotName" :slot="lane.laneId">
119
- <div class="header-slot">{{ lane.laneName }}</div>
120
- </template>
121
- <template v-for="lane in contentSlotName" :slot="lane.laneId">
122
- <div class="content-slot">
123
- <resizeEcharts autoresize :options="contentSlotOptions[lane.contentKey]" />
124
- </div>
125
- </template>
126
- </frame-layout>
463
+ <template
464
+ v-for="lane in headerSlotName"
465
+ :key="lane.laneId"
466
+ v-slot:[lane.laneId]
467
+ >
468
+ <div class="header-slot">{{ lane.laneName }}</div>
469
+ </template>
470
+
471
+ <template
472
+ v-for="lane in contentSlotName"
473
+ :key="lane.laneId"
474
+ v-slot:[lane.laneId]
475
+ >
476
+ <div class="content-slot" /><!-- 自定义岩性等 -->
127
477
  </template>
128
478
  ```
129
479
 
130
- ### Props
480
+ `@template-change` 中维护 `headerSlotName` / `contentSlotName`(`laneId` 前缀仍为 `lane` / `content` + 数字 id),逻辑与 Vue 2 相同。
131
481
 
132
- | 参数 | 类型 | 说明 |
133
- |---|---|---|
134
- | depthConfig | Object | 井深配置(templates、params) |
135
- | timeConfig | Object | 时间配置(templates、params) |
136
- | curveDatas | Object | 曲线数据,`{ type: "replace" / "append", data: [...] }` |
137
- | themeName | String | 主题:`white` / `dark` / `gray` |
138
- | toolBarConfig | Object | 工具栏配置 |
139
- | parameterPanelConfig | Object | 参数面板配置 |
140
- | WellBitDepthTimePlotConfig | Object | 井深-钻头-时间曲线面板配置 |
141
- | warningData | Array | 预警数据 |
142
-
143
- ### 事件
144
-
145
- | 事件 | 参数 | 说明 |
482
+ ---
483
+
484
+ ## 12. 事件
485
+
486
+ | 事件 | 载荷 | 说明 |
146
487
  |---|---|---|
147
- | @template-change | data | 模板变更 |
148
- | @line-change | line | 曲线变更 |
149
- | @chart-scroll | { direction, currentData } | 图表滚动(方向 top/bottom) |
150
- | @updateSettings | { key, value, settings } | 设置变更 |
151
- | @visibleDataChange | { firstValue, lastValue } | 可见数据范围变更 |
152
- | @dialogFunction | { type, start, end } | 弹窗(1-井深段,2-时间段,3-导出) |
153
- | @refresh | | 刷新 |
154
- | @onCustomMenuClicked | — | 自定义菜单点击 |
155
- | @trend-change | { paramId, laneId, segments } | 趋势线变更(加点/拖拽结束/删点/断段/重置) |
488
+ | `template-change` | 当前模板 | 拖拽/编辑后 |
489
+ | `line-change` | line + actionType | 曲线变更 |
490
+ | **`config-change`** | `{ reason, config, axisType }` | 保存/重置/拖拽/强制更新后回传 |
491
+ | `update-settings` | `{ key, value, settings }` | 切轴、切实时历史 |
492
+ | `chart-scroll` | `{ direction, currentData }` | 触顶触底 |
493
+ | `visible-data-change` | 可见窗口信息 | 自定义道跟窗 |
494
+ | `dialog-function` | `{ type, start, end }` | 井深段/时间段/导出 |
495
+ | `refresh` | — | 刷新 |
496
+ | `trend-change` | 趋势线数据 | 编辑后 |
497
+ | `show-context-menu` / `on-custom-menu-clicked` | 右键 | 菜单 |
498
+ | `lane-width-change` | 列宽 | 拖宽 |
499
+
500
+ 模板中可用 kebab-case:`@config-change`、`@update-settings`。
501
+
502
+ 建议:
156
503
 
157
- 趋势线的配置、交互和保存方式见 **[趋势线使用手册](./src/components/kdCurveV2/trend-line/趋势线使用手册.md)**。
504
+ ```js
505
+ function onConfigChange({ axisType, config, reason }) {
506
+ const target = axisType === "time" ? timeConfig : depthConfig;
507
+ target.dataSource = config.dataSource;
508
+ if (config.versionCode != null) target.versionCode = config.versionCode;
509
+ }
510
+ ```
158
511
 
159
- 对数轴(泳道 `isLogScale`、表头点值按 lg 输出、边控显隐)见 **[对数轴使用手册](./src/components/kdCurveV2/log-axis/对数轴使用手册.md)**。
512
+ 原地更新 `dataSource`,避免整对象替换导致图表不必要整页重建。
160
513
 
161
- ### 曲线数据格式
514
+ ---
515
+
516
+ ## 13. ref 方法(重点)
162
517
 
163
518
  ```js
164
- // 初始化/替换数据
165
- curveDatas: { type: "replace", data: [...] }
519
+ const fl = frameLayoutRef.value;
520
+ ```
166
521
 
167
- // 追加数据(实时更新)
168
- curveDatas: { type: "append", data: generator() }
522
+ | 方法 | 说明 |
523
+ |---|---|
524
+ | `getCurrentConfig()` | `{ axisType, config }` |
525
+ | `forceUpdateCurveConfig(nextConfig?, options?)` | 强制写内存 + IndexedDB,并 `config-change` |
526
+ | `setCurveMinMaxByParamId(paramsId, min, max)` | 改量程;模板锁定则 `false` |
527
+ | `getTrendLineData()` / `setTrendLineData(...)` | 趋势线 |
528
+ | `breakTrendSegment()` / `resetTrendLine` / `resetAllTrendLines` | 趋势线编辑 |
529
+ | `clearActiveLane()` | 清选中 |
530
+ | `clearChartData()` | 清数据 |
531
+ | `refresh()` | 内部刷新 |
532
+ | `startLoading()` / `stopLoading()` | 加载态 |
533
+ | `jumpToNextMarkLine(percent?)` | 跳预警线 |
534
+ | `updateForm({ key, value })` | 改 form |
535
+
536
+ Options API 下:`this.$refs.frameLayout.xxx()`。
537
+
538
+ ---
539
+
540
+ ## 14. 强制更新配置 forceUpdateCurveConfig
541
+
542
+ 用于**强制**用新配置覆盖当前轴(含 IndexedDB),不依赖 `versionCode` 升级路径。
543
+
544
+ ### 14.1 强制落库当前内存配置
545
+
546
+ ```js
547
+ await frameLayoutRef.value.forceUpdateCurveConfig();
548
+ ```
549
+
550
+ 流程:清空该 `caseId` 存储 → 写入当前快照 → `loadConfig` 重载 → `emit('config-change', { reason: 'force-update', axisType, config })`。
551
+
552
+ ### 14.2 传入完整新配置
553
+
554
+ ```js
555
+ await frameLayoutRef.value.forceUpdateCurveConfig({
556
+ type: "local",
557
+ caseId: "my-well-depth",
558
+ versionCode: 2,
559
+ dataSource: {
560
+ templates: [/* ... */],
561
+ params: [/* ... */],
562
+ },
563
+ });
169
564
  ```
170
565
 
566
+ ### 14.3 选项
567
+
568
+ ```js
569
+ await frameLayoutRef.value.forceUpdateCurveConfig(nextConfig, {
570
+ updateDefaultSnapshot: true, // 默认 true:同步「恢复默认」基准
571
+ });
572
+ ```
573
+
574
+ ### 14.4 与恢复默认
575
+
576
+ 初始化时会冻结首份传入的 `dataSource`。右键恢复默认优先用策略源,找不到则回退到该快照 / 当前 config。强制更新且 `updateDefaultSnapshot: true` 时,恢复基准也会换成新配置。
577
+
171
578
  ---
172
579
 
173
- ## License
580
+ ## 15. 预警 / Tooltip / 主题
581
+
582
+ 预警、色带、tooltip 格式与 Vue 2 相同。
583
+ `tooltipFormatter` **必须返回 HTML 字符串**,不要返回 VNode/DOM。
584
+
585
+ ```js
586
+ function tooltipFormatter({ series, mousePositionData }) {
587
+ return `<div>${mousePositionData?.depth ?? ""}</div>`;
588
+ }
589
+ ```
590
+
591
+ 主题:`theme-name` + `body[data-theme]`。
174
592
 
175
- MIT
593
+ ---
594
+
595
+ ## 16. 交互模式与轴标签
596
+
597
+ | `isGeomechanical` | 行为 |
598
+ |---|---|
599
+ | `false` | 窗口滚动(多泳道同步) |
600
+ | `true` | 地应力缩放/平移;可配合 `canClickSelectLane` |
601
+
602
+ 井深刻度为 HTML 叠层。缩放过程中按像素密度疏化刻度并节流刷新,减轻卡顿与「刻度挤压」;结束后再精确对齐。
603
+
604
+ 对数轴见专题手册。
605
+
606
+ ---
607
+
608
+ ## 17. 单独使用 KdLaneContainer
609
+
610
+ ```vue
611
+ <KdLaneContainer :config="depthConfig" theme-name="dark" />
612
+ ```
613
+
614
+ `config` 需含 `caseId`、`type`、`versionCode`、`dataSource`。
615
+ 同样可调用 `forceUpdateCurveConfig` / `getCurrentConfig`(在该组件 ref 上)。
616
+
617
+ ---
618
+
619
+ ## 18. 多语言
620
+
621
+ ```js
622
+ import {
623
+ setCurrentLocale,
624
+ getCurrentLocale,
625
+ installKdI18n,
626
+ localeState,
627
+ } from "kd-lane-chart-v3";
628
+
629
+ installKdI18n(app); // use(FrameLayout) 时通常已调用
630
+ setCurrentLocale("en");
631
+ ```
632
+
633
+ 比 Vue 2 包多导出:`installKdI18n`、`localeState`。
634
+
635
+ ---
636
+
637
+ ## 19. Vue 2 → Vue 3 迁移注意
638
+
639
+ | 点 | Vue 2(`kd-lane-chart`) | Vue 3(`kd-lane-chart-v3`) |
640
+ |---|---|---|
641
+ | 安装包名 | `kd-lane-chart` | `kd-lane-chart-v3` |
642
+ | 注册 | `Vue.use` | `app.use` |
643
+ | UI | Element UI | Element Plus |
644
+ | 插槽 | `:slot="id"` | `v-slot:[id]` + `:key` |
645
+ | 拖拽 peer | `vuedraggable` | `vue-draggable-plus` |
646
+ | 点击外部 | `v-click-outside` | `v3-click-outside` |
647
+ | 生命周期 | `beforeDestroy` | `beforeUnmount` |
648
+ | i18n 导出 | `setCurrentLocale` 等 | 另含 `installKdI18n`、`localeState` |
649
+ | 类型 | 无官方 d.ts(以 JS 为准) | 有 `index.d.ts` |
650
+
651
+ 业务侧 `depthConfig` / `curveDatas` / 事件名语义保持一致,迁移成本主要在工程脚手架与模板语法。
652
+
653
+ ---
654
+
655
+ ## 20. 接入检查清单
656
+
657
+ - [ ] Vue 3 + Element Plus + echarts 等 peer 已装
658
+ - [ ] `app.use(FrameLayout)`,容器有高度
659
+ - [ ] `data-theme` 与 `themeName` 一致
660
+ - [ ] 轴字段三处统一:`axisTypeList` / 数据行 / `laneKey`
661
+ - [ ] 缺测为 `null`
662
+ - [ ] 模板变更:`versionCode++` 或 `forceUpdateCurveConfig`
663
+ - [ ] 监听 `config-change` 写回业务配置
664
+ - [ ] 插槽使用 `v-slot:[name]`
665
+ - [ ] tooltip 返回字符串
666
+ - [ ] 大数据注意窗口化,避免一次渲染整井
667
+
668
+ ---
669
+
670
+ ## 21. 常见问题
671
+
672
+ **切轴后空白**
673
+ 数据缺轴字段,或 `laneKey` ≠ `axisTypeList`。
674
+
675
+ **改模板不生效**
676
+ IndexedDB 旧缓存:提高 `versionCode`,或 `forceUpdateCurveConfig(新配置)`。
677
+
678
+ **Maximum recursive updates(KdLaneContainer)**
679
+ 大数据下曾因拖拽 v-model / 频繁 `lineRange` 更新引起;请使用当前修复版本。若仍出现,避免在 watch 里同步连环全量重绘。
680
+
681
+ **缩放卡顿、井深轴挤压**
682
+ 当前版本已做密度疏化与节流;确认未把整井数据当单窗绘制。
683
+
684
+ **量程改不了**
685
+ 模板已 `templateRangeSaved`,或 `paramsId` 错误。
686
+
687
+ **恢复默认失败**
688
+ 确认首次传入的 config 完整;组件会用冻结快照回退。
689
+
690
+ ---
691
+
692
+ ## 附录:导出一览
693
+
694
+ ```js
695
+ import {
696
+ KdLaneContainer,
697
+ FrameLayout,
698
+ frameLayout,
699
+ setCurrentLocale,
700
+ getCurrentLocale,
701
+ installKdI18n,
702
+ localeState,
703
+ } from "kd-lane-chart-v3";
704
+ ```