@keneth80/k-chart 1.5.0 → 1.7.0
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/CHANGELOG.md +45 -0
- package/README.md +119 -1
- package/docs/code-graph-handoff.md +67 -3
- package/docs/functional-api.md +112 -3
- package/docs/react-nextjs.md +0 -6
- package/examples/svg-globe-map-series.ts +11 -0
- package/examples/three-constellation-series.ts +375 -0
- package/lib/core/contracts.d.ts +452 -0
- package/lib/core/contracts.d.ts.map +1 -0
- package/lib/core/contracts.js +3 -0
- package/lib/core/contracts.js.map +1 -0
- package/lib/core/create-kchart.d.ts +4 -0
- package/lib/core/create-kchart.d.ts.map +1 -0
- package/lib/core/create-kchart.js +1344 -0
- package/lib/core/create-kchart.js.map +1 -0
- package/lib/core/index.d.ts +3 -0
- package/lib/core/index.d.ts.map +1 -0
- package/lib/core/index.js +19 -0
- package/lib/core/index.js.map +1 -0
- package/lib/index.d.ts +5 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/kchart.d.ts +11 -414
- package/lib/kchart.d.ts.map +1 -1
- package/lib/kchart.js +24 -2660
- package/lib/kchart.js.map +1 -1
- package/lib/options/cursor-line.d.ts +4 -0
- package/lib/options/cursor-line.d.ts.map +1 -0
- package/lib/options/cursor-line.js +36 -0
- package/lib/options/cursor-line.js.map +1 -0
- package/lib/options/guide-line.d.ts +5 -0
- package/lib/options/guide-line.d.ts.map +1 -0
- package/lib/options/guide-line.js +129 -0
- package/lib/options/guide-line.js.map +1 -0
- package/lib/options/index.d.ts +5 -0
- package/lib/options/index.d.ts.map +1 -0
- package/lib/options/index.js +21 -0
- package/lib/options/index.js.map +1 -0
- package/lib/options/spec-area.d.ts +5 -0
- package/lib/options/spec-area.d.ts.map +1 -0
- package/lib/options/spec-area.js +112 -0
- package/lib/options/spec-area.js.map +1 -0
- package/lib/options/tooltip-note.d.ts +15 -0
- package/lib/options/tooltip-note.d.ts.map +1 -0
- package/lib/options/tooltip-note.js +265 -0
- package/lib/options/tooltip-note.js.map +1 -0
- package/lib/series/canvas-candlestick.d.ts +3 -0
- package/lib/series/canvas-candlestick.d.ts.map +1 -0
- package/lib/series/canvas-candlestick.js +204 -0
- package/lib/series/canvas-candlestick.js.map +1 -0
- package/lib/series/canvas-line.d.ts +3 -0
- package/lib/series/canvas-line.d.ts.map +1 -0
- package/lib/series/canvas-line.js +67 -0
- package/lib/series/canvas-line.js.map +1 -0
- package/lib/series/canvas-point.d.ts +3 -0
- package/lib/series/canvas-point.d.ts.map +1 -0
- package/lib/series/canvas-point.js +52 -0
- package/lib/series/canvas-point.js.map +1 -0
- package/lib/series/custom.d.ts +3 -0
- package/lib/series/custom.d.ts.map +1 -0
- package/lib/series/custom.js +6 -0
- package/lib/series/custom.js.map +1 -0
- package/lib/series/index.d.ts +9 -0
- package/lib/series/index.d.ts.map +1 -0
- package/lib/series/index.js +25 -0
- package/lib/series/index.js.map +1 -0
- package/lib/series/support/canvas.d.ts +19 -0
- package/lib/series/support/canvas.d.ts.map +1 -0
- package/lib/series/support/canvas.js +130 -0
- package/lib/series/support/canvas.js.map +1 -0
- package/lib/series/support/scale.d.ts +3 -0
- package/lib/series/support/scale.d.ts.map +1 -0
- package/lib/series/support/scale.js +14 -0
- package/lib/series/support/scale.js.map +1 -0
- package/lib/series/support/webgl.d.ts +9 -0
- package/lib/series/support/webgl.d.ts.map +1 -0
- package/lib/series/support/webgl.js +92 -0
- package/lib/series/support/webgl.js.map +1 -0
- package/lib/series/svg-globe.d.ts +3 -0
- package/lib/series/svg-globe.d.ts.map +1 -0
- package/lib/series/svg-globe.js +964 -0
- package/lib/series/svg-globe.js.map +1 -0
- package/lib/series/svg-line.d.ts +3 -0
- package/lib/series/svg-line.d.ts.map +1 -0
- package/lib/series/svg-line.js +66 -0
- package/lib/series/svg-line.js.map +1 -0
- package/lib/series/webgl-line.d.ts +3 -0
- package/lib/series/webgl-line.d.ts.map +1 -0
- package/lib/series/webgl-line.js +67 -0
- package/lib/series/webgl-line.js.map +1 -0
- package/lib/series/webgl-point.d.ts +3 -0
- package/lib/series/webgl-point.d.ts.map +1 -0
- package/lib/series/webgl-point.js +63 -0
- package/lib/series/webgl-point.js.map +1 -0
- package/lib/utils/downsample-lttb.d.ts +2 -0
- package/lib/utils/downsample-lttb.d.ts.map +1 -0
- package/lib/utils/downsample-lttb.js +60 -0
- package/lib/utils/downsample-lttb.js.map +1 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/utils/index.js +18 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/worker/index.d.ts +2 -0
- package/lib/worker/index.d.ts.map +1 -0
- package/lib/worker/index.js +18 -0
- package/lib/worker/index.js.map +1 -0
- package/lib/worker/render-worker.d.ts +2 -0
- package/lib/worker/render-worker.d.ts.map +1 -0
- package/lib/worker/render-worker.js +116 -0
- package/lib/worker/render-worker.js.map +1 -0
- package/package.json +24 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.7.0 - 2026-06-19
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Added `createTooltipNoteOption()` for pinning hover tooltip snapshots as editable chart annotations.
|
|
8
|
+
- Added draggable tooltip note headers, chart-bound position constraints, delete controls, memo textareas, and `onChange` synchronization.
|
|
9
|
+
- Added a Three.js custom-series example that renders the Aries constellation with glowing stars and linked nodes.
|
|
10
|
+
- Added reusable MapLibre place parsing and city-based place resolver utilities.
|
|
11
|
+
- Added public package entry points for `core`, `series`, `options`, `utils`, and `worker`.
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- Split the chart runtime into dedicated core, series, option, worker, and utility modules while preserving the root package API.
|
|
16
|
+
- Kept pinned annotations independent from normal hover tooltips so chart inspection continues while notes remain visible.
|
|
17
|
+
- Updated the playground, README, functional API guide, and handoff documentation for the modular imports and tooltip note workflow.
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- Constrained manually positioned tooltip notes to the chart bounds after dragging or resizing.
|
|
22
|
+
- Prevented note delete and textarea interactions from being interpreted as header dragging.
|
|
23
|
+
|
|
24
|
+
## 1.6.0 - 2026-06-18
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- Added optional globe marker drilldown with `mode: 'zoom'` for same-globe coordinate focus and `mode: 'map'` for focused Mercator map mode, both with a lightweight warp overlay and return control.
|
|
29
|
+
- Added separate Globe Zoom and Globe Map demo entries so zoom focus and flat-map drilldown can be tested independently.
|
|
30
|
+
- Added `mode: 'external-map'` for integrating a real tile map after the globe warp transition.
|
|
31
|
+
- Added the optional `@keneth80/k-chart-maplibre` adapter package with MapLibre place markers, address popups, map navigation, and a return-to-globe bridge.
|
|
32
|
+
- Added automatic map transition thresholds that use the globe's settled center coordinate after dragging.
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
- Smoothed the globe-to-map transition into camera focus, centered warp, and delayed map reveal stages.
|
|
37
|
+
- Automatic zoom drilldown now preserves the coordinate being viewed instead of recentering on a nearby marker.
|
|
38
|
+
- Reused MapLibre maps are positioned at the next destination before becoming visible.
|
|
39
|
+
- Marker activation now occurs on stationary pointer release and is cancelled after more than 5px of movement.
|
|
40
|
+
|
|
41
|
+
### Fixed
|
|
42
|
+
|
|
43
|
+
- Fixed incorrect city selection when wheel zooming near a marker.
|
|
44
|
+
- Fixed low-zoom marker input being captured by globe dragging.
|
|
45
|
+
- Fixed unsafe globe zoom restoration when returning from the flat map.
|
|
46
|
+
- Fixed previous city content briefly appearing during a subsequent map transition.
|
|
47
|
+
|
|
3
48
|
## 1.5.0 - 2026-06-14
|
|
4
49
|
|
|
5
50
|
### 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
|
|
@@ -66,6 +98,35 @@ Then open `http://127.0.0.1:9003/`.
|
|
|
66
98
|
- [React Wrapper Example](examples/react-wrapper.tsx)
|
|
67
99
|
- [Canvas Candlestick Example](examples/canvas-candlestick-series.ts)
|
|
68
100
|
- [SVG Globe Map Example](examples/svg-globe-map-series.ts)
|
|
101
|
+
- [MapLibre Globe Drilldown Adapter](packages/k-chart-maplibre/README.md)
|
|
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.
|
|
69
130
|
|
|
70
131
|
## Quick Start
|
|
71
132
|
|
|
@@ -277,7 +338,9 @@ createKChart<StockPoint>({
|
|
|
277
338
|
|
|
278
339
|
## Globe Map
|
|
279
340
|
|
|
280
|
-
SVG globe series renders latitude/longitude markers on a draggable orthographic globe. Marker coordinates use ordinary geographic values: `lat` for latitude and `lon` for longitude. Click handlers receive the original data item, projected screen position, and the original browser event. A World Atlas 110m land layer is rendered by default with country borders as a separate mesh; set `landVisible: false` to hide it, or pass `landGeoJson` to use your own GeoJSON land/country data. `landMode: 'countries'` switches the fill layer to country features so `landFill`, `landStroke`, and `landOpacity` callbacks can style countries per feature. Set `zoom: { enabled: true }` to enable wheel zoom on desktop and pinch zoom on touch devices. Add `controls: true` to show in-chart zoom controls when page scrolling makes wheel zoom awkward.
|
|
341
|
+
SVG globe series renders latitude/longitude markers on a draggable orthographic globe. Marker coordinates use ordinary geographic values: `lat` for latitude and `lon` for longitude. Click handlers receive the original data item, projected screen position, and the original browser event. A World Atlas 110m land layer is rendered by default with country borders as a separate mesh; set `landVisible: false` to hide it, or pass `landGeoJson` to use your own GeoJSON land/country data. `landMode: 'countries'` switches the fill layer to country features so `landFill`, `landStroke`, and `landOpacity` callbacks can style countries per feature. Set `zoom: { enabled: true }` to enable wheel zoom on desktop and pinch zoom on touch devices. Add `controls: true` to show in-chart zoom controls when page scrolling makes wheel zoom awkward. Set `drilldown.enabled` to let marker clicks focus a coordinate with a short warp overlay. `drilldown.mode: 'zoom'` keeps the orthographic globe and zooms into the marker, while `mode: 'map'` switches to a focused Mercator map. With `autoMapOnZoom: true`, zooming past `mapZoomThreshold` automatically selects the registered city nearest the center of the visible globe and switches to the flat map. Zooming back below `globeZoomThreshold` returns to the globe.
|
|
342
|
+
|
|
343
|
+
Use `drilldown.mode: 'external-map'` with `@keneth80/k-chart-maplibre` when the destination needs real vector/raster map tiles, roads, interactive place markers, clustering, and popups. The `onEnter` context includes `exit()`, allowing the external map's back control to restore the globe. MapLibre renders the map but does not provide restaurant or address search data; connect a separate place/geocoding provider and pass the resulting coordinates to `setPlaces()` or `addPlaces()`.
|
|
281
344
|
|
|
282
345
|
```ts
|
|
283
346
|
import {
|
|
@@ -316,6 +379,17 @@ createKChart<CityPoint>({
|
|
|
316
379
|
landStroke: 'rgba(236, 253, 245, 0.72)',
|
|
317
380
|
landOpacity: 0.58,
|
|
318
381
|
countryBordersStroke: 'rgba(236, 253, 245, 0.28)',
|
|
382
|
+
drilldown: {
|
|
383
|
+
enabled: true,
|
|
384
|
+
mode: 'map',
|
|
385
|
+
autoMapOnZoom: true,
|
|
386
|
+
mapZoomThreshold: 2.4,
|
|
387
|
+
globeZoomThreshold: 1.8,
|
|
388
|
+
focusZoom: 2.7,
|
|
389
|
+
zoomScale: 7,
|
|
390
|
+
duration: 1200,
|
|
391
|
+
resetControl: true
|
|
392
|
+
},
|
|
319
393
|
onMarkerClick: ({ data }) => {
|
|
320
394
|
window.open(data.url, '_blank', 'noopener,noreferrer');
|
|
321
395
|
}
|
|
@@ -626,6 +700,50 @@ tooltip: {
|
|
|
626
700
|
|
|
627
701
|
Custom renderer가 한 series 안에서 여러 SVG/Canvas/WebGL 요소를 그리는 경우에는 series 단위 `tooltip(context)` hook을 사용할 수 있습니다. 예를 들어 stacked column, range bar, box plot처럼 하나의 datum에서 여러 시각 요소가 나올 때 core tooltip overlay는 이 hook이 돌려준 위치와 HTML을 그대로 사용합니다.
|
|
628
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
|
+
|
|
629
747
|
```ts
|
|
630
748
|
const stackedSeries = createCustomSeries<Point>({
|
|
631
749
|
selector: 'stacked-column',
|
|
@@ -6,8 +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.
|
|
10
|
-
-
|
|
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`
|
|
11
21
|
- Worker entry: `src/kchart-render.worker.ts`
|
|
12
22
|
- Public playground source link: intentionally removed because the playground repository may become private.
|
|
13
23
|
- Local playground target: `http://127.0.0.1:9011`
|
|
@@ -19,7 +29,7 @@
|
|
|
19
29
|
flowchart TD
|
|
20
30
|
App["Consumer App / React Wrapper / Playground"]
|
|
21
31
|
API["src/index.ts"]
|
|
22
|
-
Core["src/kchart.ts"]
|
|
32
|
+
Core["src/core/create-kchart.ts"]
|
|
23
33
|
Config["KChartConfiguration<T>"]
|
|
24
34
|
Controller["KChartController<T>"]
|
|
25
35
|
State["KChartState<T>"]
|
|
@@ -36,6 +46,8 @@ flowchart TD
|
|
|
36
46
|
CanvasSeries["Canvas Series"]
|
|
37
47
|
WebglSeries["WebGL Series"]
|
|
38
48
|
Worker["OffscreenCanvas Worker"]
|
|
49
|
+
Globe["SVG Globe / Marker Interaction"]
|
|
50
|
+
MapAdapter["MapLibre Adapter Package"]
|
|
39
51
|
|
|
40
52
|
App --> API
|
|
41
53
|
API --> Core
|
|
@@ -56,8 +68,23 @@ flowchart TD
|
|
|
56
68
|
Series --> WebglSeries
|
|
57
69
|
CanvasSeries --> Worker
|
|
58
70
|
WebglSeries --> Worker
|
|
71
|
+
Series --> Globe
|
|
72
|
+
Globe --> MapAdapter
|
|
59
73
|
```
|
|
60
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
|
+
|
|
61
88
|
## Runtime Render Pipeline
|
|
62
89
|
|
|
63
90
|
```mermaid
|
|
@@ -114,6 +141,7 @@ Primary exports come from `src/kchart.ts` through `src/index.ts`.
|
|
|
114
141
|
- `createSpecAreaOption(...)`
|
|
115
142
|
- `createGuideLineOption(...)`
|
|
116
143
|
- `createCursorLineOption(...)`
|
|
144
|
+
- `createTooltipNoteOption(...)`: preserves tooltip snapshots as editable chart annotations while normal hover inspection remains active.
|
|
117
145
|
|
|
118
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.
|
|
119
147
|
|
|
@@ -142,6 +170,8 @@ Options can be passed through the unified `config.options` array. Legacy direct
|
|
|
142
170
|
| Canvas series | `createCanvasLineSeries`, `createCanvasPointSeries` | Render Canvas 2D line/point visuals. |
|
|
143
171
|
| WebGL series | `createWebglLineSeries`, `createWebglPointSeries` | Render WebGL line/point visuals. |
|
|
144
172
|
| Worker rendering | `startKChartRenderWorker`, `src/kchart-render.worker.ts` | OffscreenCanvas worker bootstrap and async line drawing. |
|
|
173
|
+
| Globe rendering | `createSvgGlobeSeries` | Orthographic globe, drag rotation, zoom controls, marker interaction, warp transition, and drilldown lifecycle. |
|
|
174
|
+
| Flat map adapter | `packages/k-chart-maplibre` | Optional MapLibre tile-map overlay, place markers, address popups, and return-to-globe bridge. |
|
|
145
175
|
|
|
146
176
|
## Data And Interaction Flow
|
|
147
177
|
|
|
@@ -187,11 +217,17 @@ Important state fields:
|
|
|
187
217
|
- `zoom.wheelZoom` and `zoom.gestureZoom` split desktop wheel/trackpad input from mobile touch gesture input without removing the older `mode` contract.
|
|
188
218
|
- Candlestick color modes support both `open-close` and `previous-close`; `previousCloseField` can point to an explicit previous close value.
|
|
189
219
|
- Globe map series uses `d3-geo` and expects ordinary `lat`/`lon` fields. It renders a built-in World Atlas 110m land layer plus country border mesh by default, accepts external GeoJSON through `landGeoJson`, supports country feature styling through `landMode: 'countries'`, `landFill`, `landStroke`, and `landOpacity`, and can enable wheel/pinch scaling plus in-chart zoom buttons through the `zoom` option.
|
|
220
|
+
- Globe drilldown supports `zoom`, internal `map`, and external `external-map` modes.
|
|
221
|
+
- Automatic external-map drilldown stores the globe center when dragging stops and warps from that settled coordinate without recentering the globe.
|
|
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.
|
|
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.
|
|
190
224
|
|
|
191
225
|
### External Packages Around This Library
|
|
192
226
|
|
|
193
227
|
- `@keneth80/k-chart-react`: separate React wrapper package.
|
|
228
|
+
- `@keneth80/k-chart-maplibre`: optional flat-map adapter package stored in this repository under `packages/k-chart-maplibre`.
|
|
194
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`.
|
|
195
231
|
|
|
196
232
|
## Known Design Decisions
|
|
197
233
|
|
|
@@ -202,6 +238,34 @@ Important state fields:
|
|
|
202
238
|
- OHLC-style charts should use axis `domainFields` so a single y-axis can derive its domain from multiple value fields such as `low` and `high`.
|
|
203
239
|
- The library does not execute user-edited JavaScript. Playground-generated configs should be validated before applying.
|
|
204
240
|
- Web Worker rendering is opt-in with `asyncRender` because bundler worker setup differs by application.
|
|
241
|
+
- Globe automatic zoom and marker clicks intentionally use separate camera behavior: automatic zoom preserves the settled viewport center, while marker activation may fly to the selected city.
|
|
242
|
+
|
|
243
|
+
## Latest Globe Interaction Flow
|
|
244
|
+
|
|
245
|
+
```txt
|
|
246
|
+
drag globe
|
|
247
|
+
-> pointerup
|
|
248
|
+
-> save projection center as [lon, lat]
|
|
249
|
+
|
|
250
|
+
automatic zoom threshold
|
|
251
|
+
-> choose nearest registered city only for associated place data
|
|
252
|
+
-> keep saved center as the drilldown coordinate
|
|
253
|
+
-> play centered warp without rotating the globe
|
|
254
|
+
-> reveal MapLibre at the saved center
|
|
255
|
+
|
|
256
|
+
marker press
|
|
257
|
+
-> track pointer movement
|
|
258
|
+
-> release within 5px: fly to marker, warp, reveal city map
|
|
259
|
+
-> release after movement: cancel activation
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Release 1.7.0 Scope
|
|
263
|
+
|
|
264
|
+
- Modular public entry points for core, series, options, utilities, and workers.
|
|
265
|
+
- Draggable pinned tooltip notes with editable memo text and change callbacks.
|
|
266
|
+
- Three.js Aries constellation custom-series example.
|
|
267
|
+
- Reusable MapLibre place parsing and city resolver utilities.
|
|
268
|
+
- Backward-compatible root exports for existing consumers.
|
|
205
269
|
|
|
206
270
|
## Verification Commands
|
|
207
271
|
|
package/docs/functional-api.md
CHANGED
|
@@ -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
|
|
54
|
+
새 저장소 기준 root public export는 `src/index.ts`이며 `src/kchart.ts`는 기존
|
|
55
|
+
내부 import 호환성을 위한 barrel입니다. 기존 class 기반 구현은 패키지 API로
|
|
56
|
+
내보내지 않습니다.
|
|
30
57
|
|
|
31
58
|
## Controller
|
|
32
59
|
|
|
@@ -172,7 +199,7 @@ const chart = createKChart<StockPoint>({
|
|
|
172
199
|
|
|
173
200
|
## Built-In SVG Globe Series
|
|
174
201
|
|
|
175
|
-
지도/지구본 데이터는 `createSvgGlobeSeries`로 렌더링합니다. 좌표는 일반 위도/경도 값을 그대로 사용하며, 내부에서는 `projection([lon, lat])`로 변환합니다. 마커 클릭 시 원본 데이터, 위도/경도, 화면 좌표, 브라우저 이벤트를 callback으로 받을 수 있습니다. 기본값으로 World Atlas 110m land layer와 국가 경계 mesh가 표시되며, `landVisible: false`로 끄거나 `landGeoJson`으로 더 정교한 GeoJSON을 교체할 수 있습니다. 나라별 색상 지정이 필요하면 `landMode: 'countries'`를 사용하고 `landFill`, `landStroke`, `landOpacity` callback을 feature 기준으로 지정합니다. `zoom: { enabled: true }`를 지정하면 데스크톱에서는 wheel zoom, 터치 장치에서는 pinch zoom을 사용할 수 있습니다. 페이지 스크롤 때문에 wheel zoom을 쓰기 어려우면 `controls: true`로 차트 오른쪽 상단의 zoom control을 표시할 수 있습니다.
|
|
202
|
+
지도/지구본 데이터는 `createSvgGlobeSeries`로 렌더링합니다. 좌표는 일반 위도/경도 값을 그대로 사용하며, 내부에서는 `projection([lon, lat])`로 변환합니다. 마커 클릭 시 원본 데이터, 위도/경도, 화면 좌표, 브라우저 이벤트를 callback으로 받을 수 있습니다. 기본값으로 World Atlas 110m land layer와 국가 경계 mesh가 표시되며, `landVisible: false`로 끄거나 `landGeoJson`으로 더 정교한 GeoJSON을 교체할 수 있습니다. 나라별 색상 지정이 필요하면 `landMode: 'countries'`를 사용하고 `landFill`, `landStroke`, `landOpacity` callback을 feature 기준으로 지정합니다. `zoom: { enabled: true }`를 지정하면 데스크톱에서는 wheel zoom, 터치 장치에서는 pinch zoom을 사용할 수 있습니다. 페이지 스크롤 때문에 wheel zoom을 쓰기 어려우면 `controls: true`로 차트 오른쪽 상단의 zoom control을 표시할 수 있습니다. `drilldown.enabled`를 켜면 마커 클릭 시 워프 효과와 함께 해당 좌표를 포커싱합니다. `mode: 'zoom'`은 기존 지구본을 유지한 채 좌표로 줌인하고, `mode: 'map'`은 해당 좌표 중심의 Mercator 평면 지도 모드로 전환합니다. `autoMapOnZoom: true`를 사용하면 `mapZoomThreshold` 이상의 확대에서 현재 지구본 정면 중심과 가장 가까운 등록 도시를 선택해 평면 지도로 자동 전환하고, `globeZoomThreshold` 이하로 축소하면 지구본으로 돌아옵니다.
|
|
176
203
|
|
|
177
204
|
```ts
|
|
178
205
|
interface CityPoint {
|
|
@@ -206,6 +233,17 @@ const chart = createKChart<CityPoint>({
|
|
|
206
233
|
landStroke: 'rgba(236, 253, 245, 0.72)',
|
|
207
234
|
landOpacity: 0.58,
|
|
208
235
|
countryBordersStroke: 'rgba(236, 253, 245, 0.28)',
|
|
236
|
+
drilldown: {
|
|
237
|
+
enabled: true,
|
|
238
|
+
mode: 'map',
|
|
239
|
+
autoMapOnZoom: true,
|
|
240
|
+
mapZoomThreshold: 2.4,
|
|
241
|
+
globeZoomThreshold: 1.8,
|
|
242
|
+
focusZoom: 2.7,
|
|
243
|
+
zoomScale: 7,
|
|
244
|
+
duration: 1200,
|
|
245
|
+
resetControl: true
|
|
246
|
+
},
|
|
209
247
|
markerColor: '#5db8ff',
|
|
210
248
|
onMarkerClick: ({ data }) => {
|
|
211
249
|
window.open(data.url, '_blank', 'noopener,noreferrer');
|
|
@@ -215,7 +253,15 @@ const chart = createKChart<CityPoint>({
|
|
|
215
253
|
});
|
|
216
254
|
```
|
|
217
255
|
|
|
218
|
-
`draggable` 기본값은 `true`입니다. `zoom` 기본값은 비활성화이며, `zoom: true` 또는 `zoom: { enabled: true }`로 켤 수 있습니다. `min`과 `max`는 기본 globe scale에 곱해지는 배율입니다. `controls: true`를 지정하면 `+`, 현재 배율, `-` 버튼이 표시되고 현재 배율 버튼은 1x로 리셋합니다. `controls: { visible: true, x, y }`의 `x`, `y`는 차트 전체 SVG의 오른쪽/위쪽 edge 기준 offset입니다. `landGeoJson`에 GeoJSON feature, feature collection, 또는 feature 배열을 넘기면 기본 land layer 대신 해당 path를 구면 위에 그립니다. `landMode: 'countries'`를 지정하면 기본 fill layer도 국가 feature 단위로 분리되어 나라별 색상 callback을 적용할 수 있습니다.
|
|
256
|
+
`draggable` 기본값은 `true`입니다. `zoom` 기본값은 비활성화이며, `zoom: true` 또는 `zoom: { enabled: true }`로 켤 수 있습니다. `min`과 `max`는 기본 globe scale에 곱해지는 배율입니다. `controls: true`를 지정하면 `+`, 현재 배율, `-` 버튼이 표시되고 현재 배율 버튼은 1x로 리셋합니다. `controls: { visible: true, x, y }`의 `x`, `y`는 차트 전체 SVG의 오른쪽/위쪽 edge 기준 offset입니다. `drilldown` 기본값은 비활성화이며, `drilldown: { enabled: true, mode: 'zoom', focusZoom: 2.7 }`로 켜면 선택 좌표가 중앙에 오도록 지구본을 회전하고 확대합니다. 기존 평면 지도 전환이 필요하면 `mode: 'map'`과 `zoomScale`을 사용합니다. 자동 전환은 `autoMapOnZoom`, `mapZoomThreshold`, `globeZoomThreshold`로 제어합니다. 두 임계값을 다르게 두는 이유는 경계 배율에서 지구본과 지도가 반복 전환되는 현상을 막기 위한 hysteresis입니다. `resetControl`이 true이면 포커스 상태에서 `G` 버튼으로 이전 지구본 상태로 돌아갑니다. `landGeoJson`에 GeoJSON feature, feature collection, 또는 feature 배열을 넘기면 기본 land layer 대신 해당 path를 구면 위에 그립니다. `landMode: 'countries'`를 지정하면 기본 fill layer도 국가 feature 단위로 분리되어 나라별 색상 callback을 적용할 수 있습니다.
|
|
257
|
+
|
|
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 등 별도 공급자에서 받아 장소 좌표 데이터로 전달해야 합니다.
|
|
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)에 있습니다.
|
|
219
265
|
|
|
220
266
|
## Built-In WebGL Series
|
|
221
267
|
|
|
@@ -360,6 +406,30 @@ createKChart({
|
|
|
360
406
|
|
|
361
407
|
The default tooltip shows the active series name and nearest x/y values. Provide `tooltip.formatter` for custom HTML/text.
|
|
362
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
|
+
|
|
363
433
|
## Option Factories
|
|
364
434
|
|
|
365
435
|
Series는 `series: [...]`로 받고, chart 부가 기능은 `options: [...]`로 받습니다.
|
|
@@ -380,6 +450,10 @@ createKChart({
|
|
|
380
450
|
}),
|
|
381
451
|
createCursorLineOption({
|
|
382
452
|
valueFormat: (value: number) => Number(value).toFixed(1)
|
|
453
|
+
}),
|
|
454
|
+
createTooltipNoteOption<Point>({
|
|
455
|
+
maxNotes: 8,
|
|
456
|
+
onChange: (notes) => console.info(notes)
|
|
383
457
|
})
|
|
384
458
|
]
|
|
385
459
|
});
|
|
@@ -401,6 +475,41 @@ Renderer context 주요 필드:
|
|
|
401
475
|
- `getCanvas(name)`: Canvas 2D layer
|
|
402
476
|
- `getWebglCanvas(name)`: WebGL canvas layer
|
|
403
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
|
+
|
|
404
513
|
```ts
|
|
405
514
|
const circleSeries = createCustomSeries<CirclePoint>({
|
|
406
515
|
selector: 'custom-circle',
|
package/docs/react-nextjs.md
CHANGED
|
@@ -254,9 +254,3 @@ createWebglLineSeries<Point>({
|
|
|
254
254
|
```
|
|
255
255
|
|
|
256
256
|
OffscreenCanvas나 Worker를 지원하지 않는 브라우저에서는 기존 main-thread renderer로 fallback됩니다.
|
|
257
|
-
|
|
258
|
-
## React Plugin 상태
|
|
259
|
-
|
|
260
|
-
- `@keneth80/k-chart` npm package에는 아직 공식 React plugin이 포함되어 있지 않습니다.
|
|
261
|
-
- `kchart-next-playground/packages/react/src`에 로컬 wrapper 예제가 있습니다.
|
|
262
|
-
- 공식 plugin으로 분리한다면 `@keneth80/k-chart-react` 같은 별도 package로 배포하는 방향이 적합합니다.
|
|
@@ -43,6 +43,17 @@ createKChart<CityPoint>({
|
|
|
43
43
|
countryBordersStroke: 'rgba(236, 253, 245, 0.28)',
|
|
44
44
|
markerRadius: (point) => point.radius,
|
|
45
45
|
markerColor: '#5db8ff',
|
|
46
|
+
drilldown: {
|
|
47
|
+
enabled: true,
|
|
48
|
+
mode: 'map',
|
|
49
|
+
autoMapOnZoom: true,
|
|
50
|
+
mapZoomThreshold: 2.4,
|
|
51
|
+
globeZoomThreshold: 1.8,
|
|
52
|
+
focusZoom: 2.7,
|
|
53
|
+
zoomScale: 7,
|
|
54
|
+
duration: 1200,
|
|
55
|
+
resetControl: true
|
|
56
|
+
},
|
|
46
57
|
onMarkerClick: ({ data }) => {
|
|
47
58
|
window.open(data.url, '_blank', 'noopener,noreferrer');
|
|
48
59
|
}
|