@keneth80/k-chart 1.6.0 → 1.7.1

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.
Files changed (110) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +104 -0
  3. package/docs/code-graph-handoff.md +35 -12
  4. package/docs/functional-api.md +97 -1
  5. package/examples/three-constellation-series.ts +375 -0
  6. package/lib/core/contracts.d.ts +452 -0
  7. package/lib/core/contracts.d.ts.map +1 -0
  8. package/lib/core/contracts.js +3 -0
  9. package/lib/core/contracts.js.map +1 -0
  10. package/lib/core/create-kchart.d.ts +4 -0
  11. package/lib/core/create-kchart.d.ts.map +1 -0
  12. package/lib/core/create-kchart.js +1344 -0
  13. package/lib/core/create-kchart.js.map +1 -0
  14. package/lib/core/index.d.ts +3 -0
  15. package/lib/core/index.d.ts.map +1 -0
  16. package/lib/core/index.js +19 -0
  17. package/lib/core/index.js.map +1 -0
  18. package/lib/index.d.ts +5 -1
  19. package/lib/index.d.ts.map +1 -1
  20. package/lib/index.js +5 -1
  21. package/lib/index.js.map +1 -1
  22. package/lib/kchart.d.ts +11 -438
  23. package/lib/kchart.d.ts.map +1 -1
  24. package/lib/kchart.js +24 -3189
  25. package/lib/kchart.js.map +1 -1
  26. package/lib/options/cursor-line.d.ts +4 -0
  27. package/lib/options/cursor-line.d.ts.map +1 -0
  28. package/lib/options/cursor-line.js +36 -0
  29. package/lib/options/cursor-line.js.map +1 -0
  30. package/lib/options/guide-line.d.ts +5 -0
  31. package/lib/options/guide-line.d.ts.map +1 -0
  32. package/lib/options/guide-line.js +129 -0
  33. package/lib/options/guide-line.js.map +1 -0
  34. package/lib/options/index.d.ts +5 -0
  35. package/lib/options/index.d.ts.map +1 -0
  36. package/lib/options/index.js +21 -0
  37. package/lib/options/index.js.map +1 -0
  38. package/lib/options/spec-area.d.ts +5 -0
  39. package/lib/options/spec-area.d.ts.map +1 -0
  40. package/lib/options/spec-area.js +112 -0
  41. package/lib/options/spec-area.js.map +1 -0
  42. package/lib/options/tooltip-note.d.ts +15 -0
  43. package/lib/options/tooltip-note.d.ts.map +1 -0
  44. package/lib/options/tooltip-note.js +265 -0
  45. package/lib/options/tooltip-note.js.map +1 -0
  46. package/lib/series/canvas-candlestick.d.ts +3 -0
  47. package/lib/series/canvas-candlestick.d.ts.map +1 -0
  48. package/lib/series/canvas-candlestick.js +204 -0
  49. package/lib/series/canvas-candlestick.js.map +1 -0
  50. package/lib/series/canvas-line.d.ts +3 -0
  51. package/lib/series/canvas-line.d.ts.map +1 -0
  52. package/lib/series/canvas-line.js +67 -0
  53. package/lib/series/canvas-line.js.map +1 -0
  54. package/lib/series/canvas-point.d.ts +3 -0
  55. package/lib/series/canvas-point.d.ts.map +1 -0
  56. package/lib/series/canvas-point.js +52 -0
  57. package/lib/series/canvas-point.js.map +1 -0
  58. package/lib/series/custom.d.ts +3 -0
  59. package/lib/series/custom.d.ts.map +1 -0
  60. package/lib/series/custom.js +6 -0
  61. package/lib/series/custom.js.map +1 -0
  62. package/lib/series/index.d.ts +9 -0
  63. package/lib/series/index.d.ts.map +1 -0
  64. package/lib/series/index.js +25 -0
  65. package/lib/series/index.js.map +1 -0
  66. package/lib/series/support/canvas.d.ts +19 -0
  67. package/lib/series/support/canvas.d.ts.map +1 -0
  68. package/lib/series/support/canvas.js +130 -0
  69. package/lib/series/support/canvas.js.map +1 -0
  70. package/lib/series/support/scale.d.ts +3 -0
  71. package/lib/series/support/scale.d.ts.map +1 -0
  72. package/lib/series/support/scale.js +14 -0
  73. package/lib/series/support/scale.js.map +1 -0
  74. package/lib/series/support/webgl.d.ts +9 -0
  75. package/lib/series/support/webgl.d.ts.map +1 -0
  76. package/lib/series/support/webgl.js +92 -0
  77. package/lib/series/support/webgl.js.map +1 -0
  78. package/lib/series/svg-globe.d.ts +3 -0
  79. package/lib/series/svg-globe.d.ts.map +1 -0
  80. package/lib/series/svg-globe.js +964 -0
  81. package/lib/series/svg-globe.js.map +1 -0
  82. package/lib/series/svg-line.d.ts +3 -0
  83. package/lib/series/svg-line.d.ts.map +1 -0
  84. package/lib/series/svg-line.js +66 -0
  85. package/lib/series/svg-line.js.map +1 -0
  86. package/lib/series/webgl-line.d.ts +3 -0
  87. package/lib/series/webgl-line.d.ts.map +1 -0
  88. package/lib/series/webgl-line.js +67 -0
  89. package/lib/series/webgl-line.js.map +1 -0
  90. package/lib/series/webgl-point.d.ts +3 -0
  91. package/lib/series/webgl-point.d.ts.map +1 -0
  92. package/lib/series/webgl-point.js +63 -0
  93. package/lib/series/webgl-point.js.map +1 -0
  94. package/lib/utils/downsample-lttb.d.ts +2 -0
  95. package/lib/utils/downsample-lttb.d.ts.map +1 -0
  96. package/lib/utils/downsample-lttb.js +60 -0
  97. package/lib/utils/downsample-lttb.js.map +1 -0
  98. package/lib/utils/index.d.ts +2 -0
  99. package/lib/utils/index.d.ts.map +1 -0
  100. package/lib/utils/index.js +18 -0
  101. package/lib/utils/index.js.map +1 -0
  102. package/lib/worker/index.d.ts +2 -0
  103. package/lib/worker/index.d.ts.map +1 -0
  104. package/lib/worker/index.js +18 -0
  105. package/lib/worker/index.js.map +1 -0
  106. package/lib/worker/render-worker.d.ts +2 -0
  107. package/lib/worker/render-worker.d.ts.map +1 -0
  108. package/lib/worker/render-worker.js +116 -0
  109. package/lib/worker/render-worker.js.map +1 -0
  110. package/package.json +23 -9
package/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.7.1 - 2026-06-19
4
+
5
+ ### Fixed
6
+
7
+ - Fixed automatic globe drilldown selecting a city such as Seoul while opening the flat map at a stale viewport coordinate in another region.
8
+ - Preserved the selected marker's latitude and longitude when wheel or button zoom crosses the automatic map threshold.
9
+ - Restored the globe automatically when MapLibre style or tile initialization fails instead of leaving an empty external-map view.
10
+ - Allowed local webpack HMR connections from both `localhost` and `127.0.0.1` without `Invalid Host/Origin header` errors.
11
+
12
+ ### Packages
13
+
14
+ - Published `@keneth80/k-chart@1.7.1`.
15
+ - Published `@keneth80/k-chart-maplibre@0.1.1`.
16
+
17
+ ## 1.7.0 - 2026-06-19
18
+
19
+ ### Added
20
+
21
+ - Added `createTooltipNoteOption()` for pinning hover tooltip snapshots as editable chart annotations.
22
+ - Added draggable tooltip note headers, chart-bound position constraints, delete controls, memo textareas, and `onChange` synchronization.
23
+ - Added a Three.js custom-series example that renders the Aries constellation with glowing stars and linked nodes.
24
+ - Added reusable MapLibre place parsing and city-based place resolver utilities.
25
+ - Added public package entry points for `core`, `series`, `options`, `utils`, and `worker`.
26
+
27
+ ### Changed
28
+
29
+ - Split the chart runtime into dedicated core, series, option, worker, and utility modules while preserving the root package API.
30
+ - Kept pinned annotations independent from normal hover tooltips so chart inspection continues while notes remain visible.
31
+ - Updated the playground, README, functional API guide, and handoff documentation for the modular imports and tooltip note workflow.
32
+
33
+ ### Fixed
34
+
35
+ - Constrained manually positioned tooltip notes to the chart bounds after dragging or resizing.
36
+ - Prevented note delete and textarea interactions from being interpreted as header dragging.
37
+
3
38
  ## 1.6.0 - 2026-06-18
4
39
 
5
40
  ### Added
package/README.md CHANGED
@@ -30,6 +30,38 @@ createKChart(config)
30
30
  - `render(context)`는 `group`, `data`, `scales`, `xScale`, `yScale`, `plotSize`, `color`, `getCanvas`, `getWebglCanvas`를 받습니다.
31
31
  - Canvas/WebGL 시각화도 renderer 안에서 필요한 layer를 받아 직접 그릴 수 있습니다.
32
32
 
33
+ ### Three.js Custom Series
34
+
35
+ Three.js는 KChart 코어 의존성이 아닙니다. 애플리케이션에서 `three`를 설치한 뒤
36
+ `createCustomSeries(...)`와 `getWebglCanvas()`를 사용해 선택적으로 결합할 수 있습니다.
37
+
38
+ ```bash
39
+ npm install three
40
+ ```
41
+
42
+ 양자리의 실제 주요 별 배치를 기반으로 별 노드와 연결선을 3D로 표현하는 전체 예제는
43
+ [`examples/three-constellation-series.ts`](examples/three-constellation-series.ts)에 있습니다.
44
+
45
+ ```ts
46
+ const constellation = createThreeConstellationSeries({
47
+ selector: 'aries',
48
+ idField: 'id',
49
+ labelField: 'label',
50
+ xField: 'x',
51
+ yField: 'y',
52
+ zField: 'z',
53
+ sizeField: 'size',
54
+ colorField: 'color',
55
+ links: [
56
+ { source: 'mesarthim', target: 'sheratan' },
57
+ { source: 'sheratan', target: 'hamal' }
58
+ ]
59
+ });
60
+ ```
61
+
62
+ 예제는 기존 KChart WebGL canvas를 Three.js renderer에 주입하고, `InstancedMesh`,
63
+ `LineSegments`, `OrbitControls`, `Raycaster`, resize 및 dispose 생명주기를 처리합니다.
64
+
33
65
  ## Install
34
66
 
35
67
  ```bash
@@ -68,6 +100,34 @@ Then open `http://127.0.0.1:9003/`.
68
100
  - [SVG Globe Map Example](examples/svg-globe-map-series.ts)
69
101
  - [MapLibre Globe Drilldown Adapter](packages/k-chart-maplibre/README.md)
70
102
 
103
+ ## Module Structure
104
+
105
+ KChart keeps its public root API compatible while separating implementation by
106
+ responsibility:
107
+
108
+ ```text
109
+ src/
110
+ ├── core/ # contracts, state, layers, scales, and chart lifecycle
111
+ ├── series/ # SVG, Canvas, WebGL, candlestick, and globe renderers
112
+ ├── options/ # spec area, fixed guide line, and cursor line
113
+ ├── worker/ # OffscreenCanvas worker entry
114
+ └── utils/ # renderer-independent algorithms such as LTTB
115
+ ```
116
+
117
+ Existing root imports continue to work. Explicit subpath imports are also
118
+ available:
119
+
120
+ ```ts
121
+ import {createKChart} from '@keneth80/k-chart/core';
122
+ import {createCanvasLineSeries} from '@keneth80/k-chart/series';
123
+ import {createGuideLineOption} from '@keneth80/k-chart/options';
124
+ import {downsampleLTTB} from '@keneth80/k-chart/utils';
125
+ import {startKChartRenderWorker} from '@keneth80/k-chart/worker';
126
+ ```
127
+
128
+ The core calls concrete renderers only through the
129
+ `KChartSeries.render(context)` contract.
130
+
71
131
  ## Quick Start
72
132
 
73
133
  ```ts
@@ -640,6 +700,50 @@ tooltip: {
640
700
 
641
701
  Custom renderer가 한 series 안에서 여러 SVG/Canvas/WebGL 요소를 그리는 경우에는 series 단위 `tooltip(context)` hook을 사용할 수 있습니다. 예를 들어 stacked column, range bar, box plot처럼 하나의 datum에서 여러 시각 요소가 나올 때 core tooltip overlay는 이 hook이 돌려준 위치와 HTML을 그대로 사용합니다.
642
702
 
703
+ ### Pinned Tooltip Notes
704
+
705
+ `createTooltipNoteOption()`을 추가하면 hover tooltip에 고정 버튼이 나타납니다. 버튼을 누르면 당시 tooltip 데이터가 차트 위의 독립적인 메모 카드로 남고, 헤더를 드래그해 위치를 옮기거나 textarea에 메모를 작성하고 삭제할 수 있습니다. 고정된 카드가 있어도 기존 hover tooltip은 계속 동작합니다.
706
+
707
+ ```ts
708
+ import {
709
+ createKChart,
710
+ createLineSeries,
711
+ createTooltipNoteOption
712
+ } from '@keneth80/k-chart';
713
+
714
+ createKChart<Point>({
715
+ selector: '#chart',
716
+ data,
717
+ tooltip: {
718
+ visible: true,
719
+ formatter: ({data, series}) =>
720
+ `<strong>${series.displayName}</strong><br/>${data.label}: ${data.value}`
721
+ },
722
+ options: [
723
+ createTooltipNoteOption<Point>({
724
+ maxNotes: 6,
725
+ pinButtonLabel: 'Pin note',
726
+ notePlaceholder: 'Write a memo...',
727
+ onChange: (notes) => {
728
+ // Save notes to application state or an API when needed.
729
+ console.info(notes);
730
+ }
731
+ })
732
+ ],
733
+ axes,
734
+ series: [
735
+ createLineSeries({
736
+ selector: 'value',
737
+ displayName: 'Value',
738
+ xField: 'x',
739
+ yField: 'value'
740
+ })
741
+ ]
742
+ }).render();
743
+ ```
744
+
745
+ `onChange` receives the current `KChartTooltipNote<T>[]` after pin, memo edit, and delete. Notes live for the chart controller lifetime and are removed by `chart.destroy()`. Persist them externally through `onChange` when they must survive a page reload.
746
+
643
747
  ```ts
644
748
  const stackedSeries = createCustomSeries<Point>({
645
749
  selector: 'stacked-column',
@@ -6,9 +6,18 @@
6
6
 
7
7
  - Package: `@keneth80/k-chart`
8
8
  - Current public API style: class-free functional runtime
9
- - Current release baseline: `1.6.0`
10
- - Release branch at handoff: `release/1.6.0`
11
- - Main source entry: `src/index.ts` -> `src/kchart.ts`
9
+ - Current release baseline: `1.6.0` published on 2026-06-18
10
+ - Current integration branch at handoff: `develop`
11
+ - Release tag: `v1.6.0`
12
+ - Published packages:
13
+ - `@keneth80/k-chart@1.6.0`
14
+ - MapLibre publication status:
15
+ - `npm publish --access public` accepted `@keneth80/k-chart-maplibre@0.1.0`.
16
+ - Registry lookup still returned `E404` immediately afterward; verify package visibility before depending on the public package.
17
+ - Main source entry: `src/index.ts`
18
+ - Backward-compatible barrel: `src/kchart.ts`
19
+ - Core runtime: `src/core/create-kchart.ts`
20
+ - Shared contracts: `src/core/contracts.ts`
12
21
  - Worker entry: `src/kchart-render.worker.ts`
13
22
  - Public playground source link: intentionally removed because the playground repository may become private.
14
23
  - Local playground target: `http://127.0.0.1:9011`
@@ -20,7 +29,7 @@
20
29
  flowchart TD
21
30
  App["Consumer App / React Wrapper / Playground"]
22
31
  API["src/index.ts"]
23
- Core["src/kchart.ts"]
32
+ Core["src/core/create-kchart.ts"]
24
33
  Config["KChartConfiguration<T>"]
25
34
  Controller["KChartController<T>"]
26
35
  State["KChartState<T>"]
@@ -63,6 +72,19 @@ flowchart TD
63
72
  Globe --> MapAdapter
64
73
  ```
65
74
 
75
+ ## Module Ownership
76
+
77
+ - `src/core/contracts.ts`: public types and renderer contracts.
78
+ - `src/core/create-kchart.ts`: state, layers, scales, axes, legend, tooltip,
79
+ zoom, lifecycle, and renderer orchestration.
80
+ - `src/series/`: concrete SVG, Canvas, WebGL, candlestick, and globe series.
81
+ - `src/options/`: option factories and option rendering behavior.
82
+ - `src/worker/`: OffscreenCanvas worker runtime.
83
+ - `src/utils/`: renderer-independent algorithms.
84
+
85
+ Dependency direction is `series/options -> core contracts`. The core receives
86
+ concrete series through configuration and does not own their implementations.
87
+
66
88
  ## Runtime Render Pipeline
67
89
 
68
90
  ```mermaid
@@ -119,6 +141,7 @@ Primary exports come from `src/kchart.ts` through `src/index.ts`.
119
141
  - `createSpecAreaOption(...)`
120
142
  - `createGuideLineOption(...)`
121
143
  - `createCursorLineOption(...)`
144
+ - `createTooltipNoteOption(...)`: preserves tooltip snapshots as editable chart annotations while normal hover inspection remains active.
122
145
 
123
146
  Options can be passed through the unified `config.options` array. Legacy direct fields such as `specAreas`, `guideLines`, and `cursorGuide` are still read by the renderer.
124
147
 
@@ -197,13 +220,14 @@ Important state fields:
197
220
  - Globe drilldown supports `zoom`, internal `map`, and external `external-map` modes.
198
221
  - Automatic external-map drilldown stores the globe center when dragging stops and warps from that settled coordinate without recentering the globe.
199
222
  - Direct marker activation remains a city-focused transition. It fires on pointer release only when movement stays within 5px, preventing marker drags from being treated as clicks.
200
- - `packages/k-chart-maplibre` provides `createMapLibreFlatMap` and `createMapLibreGlobeBridge`. A reused map is positioned at the next destination before its overlay is revealed, preventing the previous city from flashing.
223
+ - `packages/k-chart-maplibre` provides `createMapLibreFlatMap`, `createMapLibreGlobeBridge`, `parseMapLibrePlaces`, and `createMapLibrePlaceResolver`. Provider-specific place records are normalized and validated before a city-indexed resolver supplies them to the globe bridge. A reused map is positioned at the next destination before its overlay is revealed, preventing the previous city from flashing.
201
224
 
202
225
  ### External Packages Around This Library
203
226
 
204
227
  - `@keneth80/k-chart-react`: separate React wrapper package.
205
228
  - `@keneth80/k-chart-maplibre`: optional flat-map adapter package stored in this repository under `packages/k-chart-maplibre`.
206
229
  - KChart Next playground: separate app used for examples, editable configuration, and AI Builder. Its GitHub source link should not be exposed from public library docs while it is private or planned private.
230
+ - Three.js integration is currently an optional custom-series example on `feature/three-constellation-series`, not a core runtime dependency. The demo uses `InstancedMesh`, `LineSegments`, `OrbitControls`, and `Raycaster`.
207
231
 
208
232
  ## Known Design Decisions
209
233
 
@@ -235,14 +259,13 @@ marker press
235
259
  -> release after movement: cancel activation
236
260
  ```
237
261
 
238
- ## Release 1.6.0 Scope
262
+ ## Release 1.7.1 Scope
239
263
 
240
- - Globe zoom focus and internal Mercator drilldown examples.
241
- - Automatic zoom-threshold transition and safe return zoom.
242
- - Optional MapLibre flat-map adapter with real map tiles and place markers.
243
- - Smoothed warp/reveal transition.
244
- - Settled-center preservation for automatic drilldown.
245
- - Reliable low-zoom marker activation on stationary pointer release.
264
+ - Automatic globe drilldown keeps the selected city label and map coordinate consistent.
265
+ - Wheel and button zoom use registered marker coordinates when entering the flat map.
266
+ - MapLibre initialization failures restore the globe instead of leaving an empty view.
267
+ - Local demo HMR accepts both `localhost` and `127.0.0.1`.
268
+ - Companion adapter release: `@keneth80/k-chart-maplibre@0.1.1`.
246
269
 
247
270
  ## Verification Commands
248
271
 
@@ -1,5 +1,29 @@
1
1
  # KChart Functional API
2
2
 
3
+ ## Package Boundaries
4
+
5
+ The root package remains backward compatible. Internally, implementation is
6
+ separated into `core`, `series`, `options`, `worker`, and `utils` modules.
7
+
8
+ ```ts
9
+ import {createKChart} from '@keneth80/k-chart/core';
10
+ import {
11
+ createLineSeries,
12
+ createCanvasLineSeries,
13
+ createWebglLineSeries
14
+ } from '@keneth80/k-chart/series';
15
+ import {
16
+ createSpecAreaOption,
17
+ createGuideLineOption,
18
+ createCursorLineOption,
19
+ createTooltipNoteOption
20
+ } from '@keneth80/k-chart/options';
21
+ ```
22
+
23
+ Series implementations depend on shared core contracts. The core runtime does
24
+ not contain concrete line, point, candlestick, WebGL, or globe series
25
+ implementations.
26
+
3
27
  ## Goal
4
28
 
5
29
  KChart의 새 public API는 class adapter가 아니라 class-free runtime입니다. UI에서는 `new BasicChart(...)` 같은 인스턴스를 직접 만들지 않고 `createKChart(...)`로 controller를 생성합니다.
@@ -19,6 +43,7 @@ import {
19
43
  createCanvasPointSeries,
20
44
  createSvgGlobeSeries,
21
45
  createSpecAreaOption,
46
+ createTooltipNoteOption,
22
47
  createWebglPointSeries,
23
48
  createCustomSeries,
24
49
  KChartController,
@@ -26,7 +51,9 @@ import {
26
51
  } from '@keneth80/k-chart';
27
52
  ```
28
53
 
29
- 새 저장소 기준 public export는 `src/kchart.ts`입니다. 기존 class 기반 구현은 마이그레이션 참고용 source로 남아 있어도 패키지 API로는 내보내지 않습니다.
54
+ 새 저장소 기준 root public export는 `src/index.ts`이며 `src/kchart.ts`는 기존
55
+ 내부 import 호환성을 위한 barrel입니다. 기존 class 기반 구현은 패키지 API로
56
+ 내보내지 않습니다.
30
57
 
31
58
  ## Controller
32
59
 
@@ -230,6 +257,12 @@ const chart = createKChart<CityPoint>({
230
257
 
231
258
  실제 도로·건물 타일 지도가 필요한 경우 `mode: 'external-map'`을 사용합니다. 이 모드에서는 KChart가 내부 SVG 평면도를 그리지 않고 `onEnter` 콜백에 `{ data, lat, lon, exit }`를 전달합니다. `@keneth80/k-chart-maplibre` 어댑터는 이 컨텍스트를 받아 MapLibre 지도를 표시하며, 어댑터의 `G` 버튼은 `exit()`을 호출해 지구본으로 복귀합니다. MapLibre는 지도 렌더러이므로 주소 변환과 맛집 검색은 Kakao Local API, Naver Maps, MapTiler Geocoding 등 별도 공급자에서 받아 장소 좌표 데이터로 전달해야 합니다.
232
259
 
260
+ 외부 장소 API 응답은 `parseMapLibrePlaces()`로 `id`, `name`, `lat`, `lon`을
261
+ 검증·변환할 수 있습니다. `createMapLibrePlaceResolver()`는 변환된 장소를 도시별로
262
+ 한 번 인덱싱하고 `createMapLibreGlobeBridge()`에 바로 전달할 resolver를 반환합니다.
263
+ 완전히 실행 가능한 예제와 import 목록은
264
+ [`packages/k-chart-maplibre/README.md`](../packages/k-chart-maplibre/README.md)에 있습니다.
265
+
233
266
  ## Built-In WebGL Series
234
267
 
235
268
  ```ts
@@ -373,6 +406,30 @@ createKChart({
373
406
 
374
407
  The default tooltip shows the active series name and nearest x/y values. Provide `tooltip.formatter` for custom HTML/text.
375
408
 
409
+ ### Pinned Tooltip Notes
410
+
411
+ Tooltip notes are opt-in. `createTooltipNoteOption()` adds a pin action to the normal hover tooltip and renders each pinned snapshot as an editable annotation card over the chart. Drag a card header to move it without changing the original data coordinates. Pinned cards do not replace or block later hover tooltips.
412
+
413
+ ```ts
414
+ createKChart<Point>({
415
+ selector: '#chart',
416
+ data,
417
+ axes,
418
+ tooltip: {visible: true},
419
+ options: [
420
+ createTooltipNoteOption<Point>({
421
+ maxNotes: 8,
422
+ pinButtonLabel: 'Pin',
423
+ notePlaceholder: 'Add context...',
424
+ onChange: (notes) => saveNotes(notes)
425
+ })
426
+ ],
427
+ series
428
+ });
429
+ ```
430
+
431
+ The `onChange` callback receives `KChartTooltipNote<T>[]` whenever a note is pinned, edited, or deleted. Note state is scoped to the chart controller and is cleared by `destroy()`.
432
+
376
433
  ## Option Factories
377
434
 
378
435
  Series는 `series: [...]`로 받고, chart 부가 기능은 `options: [...]`로 받습니다.
@@ -393,6 +450,10 @@ createKChart({
393
450
  }),
394
451
  createCursorLineOption({
395
452
  valueFormat: (value: number) => Number(value).toFixed(1)
453
+ }),
454
+ createTooltipNoteOption<Point>({
455
+ maxNotes: 8,
456
+ onChange: (notes) => console.info(notes)
396
457
  })
397
458
  ]
398
459
  });
@@ -414,6 +475,41 @@ Renderer context 주요 필드:
414
475
  - `getCanvas(name)`: Canvas 2D layer
415
476
  - `getWebglCanvas(name)`: WebGL canvas layer
416
477
 
478
+ ### Three.js renderer 연결
479
+
480
+ Three.js 같은 외부 렌더링 엔진도 동일한 함수형 확장 지점을 사용합니다. KChart는
481
+ plot 영역 크기와 WebGL canvas를 제공하고, custom series가 Three.js scene, camera,
482
+ controls, raycaster를 소유합니다.
483
+
484
+ ```ts
485
+ import * as THREE from 'three';
486
+ import { createCustomSeries } from '@keneth80/k-chart';
487
+
488
+ let renderer: THREE.WebGLRenderer | undefined;
489
+
490
+ const series = createCustomSeries<Node>({
491
+ selector: 'three-network',
492
+ render({ getWebglCanvas, plotSize }) {
493
+ const canvas = getWebglCanvas('three-network');
494
+ renderer ??= new THREE.WebGLRenderer({
495
+ canvas,
496
+ antialias: true,
497
+ alpha: true
498
+ });
499
+ renderer.setSize(plotSize.width, plotSize.height, false);
500
+ // Build or update THREE.Scene objects from chart data.
501
+ },
502
+ destroy() {
503
+ renderer?.dispose();
504
+ renderer = undefined;
505
+ }
506
+ });
507
+ ```
508
+
509
+ 렌더러를 매 render마다 새로 생성하지 않도록 factory closure에 상태를 보관해야 합니다.
510
+ animation frame, controls, geometry, material도 `destroy()`에서 정리합니다. 전체 양자리
511
+ 별자리 예제는 `examples/three-constellation-series.ts`를 참고합니다.
512
+
417
513
  ```ts
418
514
  const circleSeries = createCustomSeries<CirclePoint>({
419
515
  selector: 'custom-circle',