@keneth80/k-chart 1.26.1 → 1.28.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/README.md +131 -1100
  3. package/docs/code-graph-handoff.md +19 -37
  4. package/docs/configuration-reference.md +16 -1
  5. package/docs/functional-api.md +87 -0
  6. package/docs/react-nextjs.md +62 -8
  7. package/docs/refactor-plan.md +39 -23
  8. package/docs/release.md +9 -4
  9. package/examples/stackblitz-simple-api-basic/package-lock.json +96 -4
  10. package/examples/stackblitz-simple-api-basic/package.json +1 -1
  11. package/examples/stackblitz-subcell-heatmap-basic/README.md +48 -0
  12. package/examples/stackblitz-subcell-heatmap-basic/index.html +13 -0
  13. package/examples/stackblitz-subcell-heatmap-basic/package-lock.json +1788 -0
  14. package/examples/stackblitz-subcell-heatmap-basic/package.json +23 -0
  15. package/examples/stackblitz-subcell-heatmap-basic/src/app.ts +212 -0
  16. package/examples/stackblitz-subcell-heatmap-basic/src/component.css +169 -0
  17. package/examples/stackblitz-subcell-heatmap-basic/src/heatmap-demo-core.ts +505 -0
  18. package/examples/stackblitz-subcell-heatmap-basic/src/heatmap-demo.ts +23 -0
  19. package/examples/stackblitz-subcell-heatmap-basic/src/main.ts +15 -0
  20. package/examples/stackblitz-subcell-heatmap-basic/src/maplibre-compat.ts +6 -0
  21. package/examples/stackblitz-subcell-heatmap-basic/src/model.ts +242 -0
  22. package/examples/stackblitz-subcell-heatmap-basic/src/raster.ts +121 -0
  23. package/examples/stackblitz-subcell-heatmap-basic/src/style.css +15 -0
  24. package/examples/stackblitz-subcell-heatmap-basic/src/synthetic.ts +72 -0
  25. package/examples/stackblitz-subcell-heatmap-basic/src/vendor.d.ts +3 -0
  26. package/examples/stackblitz-subcell-heatmap-basic/src/vite-env.d.ts +1 -0
  27. package/examples/stackblitz-topology-basic/package-lock.json +96 -4
  28. package/examples/stackblitz-topology-basic/package.json +1 -1
  29. package/examples/stackblitz-webgl-line-basic/package-lock.json +96 -4
  30. package/examples/stackblitz-webgl-line-basic/package.json +1 -1
  31. package/examples/stackblitz-world-activity-map/package.json +1 -1
  32. package/lib/core/contracts.d.ts +14 -2
  33. package/lib/core/contracts.d.ts.map +1 -1
  34. package/lib/internal/map-move-end.d.ts +8 -0
  35. package/lib/internal/map-move-end.d.ts.map +1 -0
  36. package/lib/internal/map-move-end.js +33 -0
  37. package/lib/internal/map-move-end.js.map +1 -0
  38. package/lib/series/svg-globe.d.ts.map +1 -1
  39. package/lib/series/svg-globe.js +66 -8
  40. package/lib/series/svg-globe.js.map +1 -1
  41. package/lib/series/svg-graph.d.ts +29 -0
  42. package/lib/series/svg-graph.d.ts.map +1 -1
  43. package/lib/series/svg-graph.js +509 -80
  44. package/lib/series/svg-graph.js.map +1 -1
  45. package/lib/series/svg-region-map.d.ts.map +1 -1
  46. package/lib/series/svg-region-map.js +72 -1
  47. package/lib/series/svg-region-map.js.map +1 -1
  48. package/package.json +4 -3
@@ -6,21 +6,21 @@
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` published on 2026-06-18
10
- - Current integration branch at handoff: `develop`
11
- - Release tag: `v1.6.0`
9
+ - Current release baseline: `1.27.0`
10
+ - Current integration branch at handoff: `main`
11
+ - Release tag: `v1.27.0`
12
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.
13
+ - `@keneth80/k-chart@1.27.0`
14
+ - `@keneth80/k-chart-react@0.2.1` (official React wrapper, maintained in [keneth80/k-chart-react](https://github.com/keneth80/k-chart-react))
15
+ - `@keneth80/k-chart-maplibre@0.2.0`
16
+ - `@keneth80/k-chart-cesium@0.1.5`
17
+ - `@keneth80/k-chart-three@0.1.0`
17
18
  - Main source entry: `src/index.ts`
18
19
  - Backward-compatible barrel: `src/kchart.ts`
19
20
  - Core runtime: `src/core/create-kchart.ts`
20
21
  - Shared contracts: `src/core/contracts.ts`
21
22
  - Worker entry: `src/kchart-render.worker.ts`
22
- - Public playground source link: intentionally removed because the playground repository may become private.
23
- - Local playground target: `http://127.0.0.1:9011`
23
+ - Public playground: `https://k-chart-playground.vercel.app/`
24
24
  - Library demo target: `http://127.0.0.1:9003`
25
25
 
26
26
  ## High-Level Code Graph
@@ -114,7 +114,7 @@ sequenceDiagram
114
114
 
115
115
  ## Public API Surface
116
116
 
117
- Primary exports come from `src/kchart.ts` through `src/index.ts`.
117
+ Primary exports come from `src/index.ts`. `src/kchart.ts` remains a compatibility barrel for supported functional imports; it is not a legacy class runtime.
118
118
 
119
119
  ### Chart Runtime
120
120
 
@@ -147,7 +147,7 @@ Options can be passed through the unified `config.options` array. Legacy direct
147
147
 
148
148
  ### Performance APIs
149
149
 
150
- - `downsampleLTTB<T>(data, threshold, xAccessor, yAccessor)`
150
+ - `downsampleLTTB<T>(data, threshold, xAccessor, yAccessor)` and the pixel-column min/max strategy
151
151
  - `startKChartRenderWorker(scope?)`
152
152
  - Series-level `downsample`
153
153
  - Series-level `asyncRender`
@@ -157,7 +157,7 @@ Options can be passed through the unified `config.options` array. Legacy direct
157
157
  | Area | Main Location | Responsibility |
158
158
  | --- | --- | --- |
159
159
  | Public exports | `src/index.ts` | Re-export public KChart API. |
160
- | Types and config contracts | `src/kchart.ts` top section | Define axes, series, tooltip, zoom, option, and controller contracts. |
160
+ | Types and config contracts | `src/core/contracts.ts` | Define axes, series, tooltip, zoom, option, and controller contracts. |
161
161
  | Container and layers | `createLayers`, `ensureCanvas` | Create/reuse SVG root, plot groups, overlay, Canvas, and WebGL canvas layers. |
162
162
  | Layout | `resolveSize`, `resolveEffectiveMargin` | Calculate size and dynamic top margin for title, legend, and option labels. |
163
163
  | Scales and axes | `resolveAxisDomain`, `resolveScales`, `renderAxes` | Build D3 scales and render axes/titles. |
@@ -165,7 +165,7 @@ Options can be passed through the unified `config.options` array. Legacy direct
165
165
  | Legend | `renderLegend` | Render selectable series legend and update visibility. |
166
166
  | Tooltip and cursor guide | `renderTooltip` | Hit-test series, show tooltip, draw cursor line and value labels. |
167
167
  | Zoom | `renderZoom`, `resolveZoomedAxes`, `resolveSelectionZoomAxes` | Wheel zoom, mobile gesture zoom, drag pan, selection zoom, double-click reset. |
168
- | Downsampling | `downsampleLTTB`, `resolveSeriesRenderData` | Reduce line data before rendering while preserving shape. |
168
+ | Downsampling | `src/internal/downsample.ts`, `src/utils/downsample-lttb.ts` | Reduce line data with LTTB or pixel-column min/max before rendering while preserving important shape. |
169
169
  | SVG series | `createLineSeries` | Render SVG line/dot visuals. |
170
170
  | Canvas series | `createCanvasLineSeries`, `createCanvasPointSeries` | Render Canvas 2D line/point visuals. |
171
171
  | WebGL series | `createWebglLineSeries`, `createWebglPointSeries` | Render WebGL line/point visuals. |
@@ -227,11 +227,11 @@ Important state fields:
227
227
 
228
228
  ### External Packages Around This Library
229
229
 
230
- - `@keneth80/k-chart-react`: separate React wrapper package.
230
+ - `@keneth80/k-chart-react@0.2.1`: separately published official React wrapper package. Repository: [keneth80/k-chart-react](https://github.com/keneth80/k-chart-react).
231
231
  - `@keneth80/k-chart-maplibre`: optional flat-map adapter package stored in this repository under `packages/k-chart-maplibre`.
232
232
  - `@keneth80/k-chart-cesium`: optional CesiumJS globe and movement-route adapter stored in this repository under `packages/k-chart-cesium`.
233
233
  - 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.
234
- - 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`.
234
+ - `@keneth80/k-chart-three` is a published optional adapter, not a core runtime dependency. Its examples use `InstancedMesh`, `LineSegments`, `OrbitControls`, and `Raycaster`.
235
235
 
236
236
  ## Known Design Decisions
237
237
 
@@ -263,7 +263,7 @@ marker press
263
263
  -> release after movement: cancel activation
264
264
  ```
265
265
 
266
- ## Release 1.7.1 Scope
266
+ ## Historical Release 1.7.1 Scope
267
267
 
268
268
  - Automatic globe drilldown keeps the selected city label and map coordinate consistent.
269
269
  - Wheel and button zoom use registered marker coordinates when entering the flat map.
@@ -289,24 +289,6 @@ npm run dev
289
289
 
290
290
  Then open `http://127.0.0.1:9003/`.
291
291
 
292
- ## Next Good Work Items
293
-
294
- - Split `src/kchart.ts` into smaller modules once API behavior is stable:
295
- - `core/types.ts`
296
- - `core/layout.ts`
297
- - `core/scales.ts`
298
- - `core/interactions.ts`
299
- - `series/svg.ts`
300
- - `series/canvas.ts`
301
- - `series/webgl.ts`
302
- - `options/*.ts`
303
- - Add unit tests for:
304
- - `downsampleLTTB`
305
- - `resolveEffectiveMargin`
306
- - zoom domain calculation
307
- - option array normalization
308
- - Add browser-level regression checks for:
309
- - legend hit visibility
310
- - stacked/column tooltip behavior
311
- - topology hover behavior in the playground/wrapper layer
312
- - Keep release notes in `CHANGELOG.md` aligned with npm versions.
292
+ Current feature work is tracked in GitHub issues and `CHANGELOG.md`. Keep this
293
+ snapshot aligned with package versions and module ownership when the public
294
+ architecture changes.
@@ -336,12 +336,17 @@ createKChart({
336
336
  | `valueField` | `keyof T & string` | required | node 크기와 edge 굵기에 사용할 metric입니다. 숫자로 변환할 수 없는 값은 `0`으로 처리합니다. |
337
337
  | `categoryField` | `keyof T & string` | - | category별 node 색상 field입니다. 누락값은 `N/A`로 분류합니다. |
338
338
  | `categorySide` | `source \| target \| both` | `source` | row의 category를 어느 쪽 node에 적용할지 정합니다. |
339
- | `layout` | `force \| circular` | `force` | force-directed 또는 원형 배치를 선택합니다. |
339
+ | `layout` | `force \| circular \| layered` | `force` | force-directed, 원형, source-target 계층 배치를 선택합니다. |
340
+ | `nodeRank` | `number \| (node, index) => number` | topology 기반 | `layered`에서 node의 layer를 정합니다. rank `0`이 위에 오며 같은 rank는 가로 행으로 배치됩니다. |
340
341
  | `directed` | `boolean` | `false` | `edgeSymbols` 미지정 시 target 화살표를 표시할지 정합니다. |
341
342
  | `edgeSymbols` | `none-none \| none-arrow \| circle-circle \| circle-arrow` | directed에 따라 결정 | edge 시작/끝 장식입니다. |
343
+ | `palette` / `nodeColor` | colors / `string \| (node, index) => string` | category/chart color | category palette 또는 node별 fill 색상을 설정합니다. |
342
344
  | `nodeMinRadius` / `nodeMaxRadius` | `number` | `9`, `28` | node metric을 매핑할 반지름 범위입니다. |
345
+ | `edgeColor` | `string \| (edge, index) => string` | metallic gray | edge stroke 색상입니다. |
346
+ | `edgeDash` | `string \| null \| (edge, index) => string \| null` | solid | SVG `stroke-dasharray` 값입니다. `null`은 실선입니다. |
343
347
  | `edgeMinWidth` / `edgeMaxWidth` | `number` | `1`, `7` | edge metric을 매핑할 stroke width 범위입니다. |
344
348
  | `chargeStrength` | `number` | `-360` | force layout의 node 반발력입니다. |
349
+ | `gravity` | `number` | `0` | `0`보다 클 때 force layout에 중앙 방향 `forceX`/`forceY`를 추가합니다. |
345
350
  | `linkDistance` | `number` | plot 크기 기반 | force layout의 선호 edge 길이입니다. |
346
351
  | `collisionPadding` | `number` | `8` | node 충돌 방지 여백입니다. |
347
352
  | `iterations` | `number` | `220` | 동기 force simulation tick 횟수입니다. |
@@ -366,6 +371,8 @@ createGraphSeries<Relation>({
366
371
  });
367
372
  ```
368
373
 
374
+ `edgeColor` callback은 edge stroke에 적용되지만, arrow/circle marker는 series가 공유하므로 callback별 색상을 지원하지 않고 기본 marker 색상을 사용합니다. `layered`는 순환 관계를 strongly connected component로 묶은 뒤 barycenter 순서로 edge 교차를 줄입니다. plot이 조밀하면 label 영역을 포함해 rank 행을 줄바꿈하고 node, 간격, label을 같은 비율로 축소하여 겹침과 잘림을 방지합니다.
375
+
369
376
  Graph가 직접 node hover/click 및 roaming을 처리해야 하는 화면에서는 chart-level `tooltip`과 `zoom`을 끄는 구성을 권장합니다. 코어 tooltip overlay가 필요한 경우 Graph의 `tooltip()` hit-test도 동작하지만, overlay가 SVG node의 직접 pointer event보다 위에 놓일 수 있습니다.
370
377
 
371
378
  ### SVG Tree: `createTreeSeries`
@@ -641,6 +648,7 @@ WebGL point는 현재 interleaved buffer `[x, y, size]` 구조로 GPU에 전달
641
648
  | `bubbles` | `KChartGeoRegionMapBubble[]` | `[]` | 위도/경도 기반 원형 bubble marker입니다. `value` 또는 `radius`로 크기를 조절합니다. |
642
649
  | `markers` | `KChartGeoRegionMapMarker[]` | `[]` | 위도/경도 기반 사진/라벨/pin marker입니다. `imageUrl`, `labelPosition`, `onClick`을 지원합니다. |
643
650
  | `tooltip` | `boolean \| { formatter }` | enabled | region tooltip입니다. |
651
+ | `onMoveEnd` | `(context: KChartMapMoveEndContext) => void` | - | 사용자 wheel/pan/zoom button 이동이 실제로 끝났을 때 중심 좌표를 전달합니다. |
644
652
 
645
653
  `zoom: {enabled: true, controls: {visible: true}, scaleExtent: [1, 7]}`처럼 지정하면 축이 없는 지도에서도 확대/축소와 drag 이동을 사용할 수 있습니다. `wheel`은 mouse wheel zoom, `pan`은 drag pan 입력을 제어합니다. `labels.mode: 'callout'`은 작은 지도의 라벨 선이 복잡해질 수 있으므로, choropleth 지도에서는 `centroid`와 짧은 label formatter를 우선 권장합니다.
646
654
 
@@ -662,6 +670,13 @@ WebGL point는 현재 interleaved buffer `[x, y, size]` 구조로 GPU에 전달
662
670
  | `markerRadius` | `number \| (point) => number` | implementation default | marker 크기입니다. |
663
671
  | `markerColor` | `string \| (point) => string` | implementation default | marker 색상입니다. |
664
672
  | `onMarkerClick` | `(context) => void` | - | marker click callback입니다. `data`, `lat`, `lon`, `x`, `y`, `event`를 받습니다. |
673
+ | `onMoveEnd` | `(context: KChartMapMoveEndContext) => void` | - | 사용자 drag/pinch/wheel/zoom button 이동이 실제로 끝났을 때 현재 projection 중심을 전달합니다. |
674
+
675
+ `KChartMapMoveEndContext`는 `{lon, lat, x, y}`입니다. `x`, `y`는 drawable 또는 canvas 좌상단 기준 CSS pixel 중심이며, `lon`, `lat`는 그 지점의 경도/위도입니다. SVG 지도와 MapLibre에서는 중심을 역투영하고, Cesium에서 지구 표면을 pick하지 못한 경우에만 `lon`, `lat`가 `null`일 수 있습니다.
676
+
677
+ ### Map Adapters: move completion
678
+
679
+ `KChartMapLibreConfiguration.onMoveEnd`와 `KChartCesiumConfiguration.onMoveEnd`도 같은 context를 사용합니다. MapLibre callback은 native gesture/navigation control의 `moveend`를 보고하지만 `show`, `flyTo`, cluster expansion `easeTo`, 초기화와 resize는 제외합니다. Cesium callback은 사용자 카메라 이동 완료를 보고하며 초기 view, route `flyTo`, tracking, resize는 제외합니다.
665
680
 
666
681
  ## Downsampling Configuration
667
682
 
@@ -28,6 +28,35 @@ configuration. Series implementations depend on shared core contracts. The core
28
28
  runtime does not contain concrete line, point, candlestick, WebGL, or globe
29
29
  series implementations.
30
30
 
31
+ ## Granular Imports And Bundle Scope
32
+
33
+ Category entry points keep imports readable while allowing applications to load only the parts they use:
34
+
35
+ ```ts
36
+ import {createKChart} from '@keneth80/k-chart/core';
37
+ import {createLineChart, chartConfig} from '@keneth80/k-chart/presets';
38
+ import {createCanvasLineSeries} from '@keneth80/k-chart/series';
39
+ import {createGuideLineOption} from '@keneth80/k-chart/options';
40
+ import {downsampleLTTB} from '@keneth80/k-chart/utils';
41
+ import {startKChartRenderWorker} from '@keneth80/k-chart/worker';
42
+ ```
43
+
44
+ Concrete entry points are available when a build should expose the narrowest possible dependency surface:
45
+
46
+ ```ts
47
+ import {createKChart} from '@keneth80/k-chart/core/create-kchart';
48
+ import type {
49
+ KChartAxis,
50
+ KChartController,
51
+ KChartSeries
52
+ } from '@keneth80/k-chart/core/contracts';
53
+ import {createLineSeries} from '@keneth80/k-chart/series/svg-line';
54
+ import {createCanvasLineSeries} from '@keneth80/k-chart/series/canvas-line';
55
+ import {createWebglLineSeries} from '@keneth80/k-chart/series/webgl-line';
56
+ ```
57
+
58
+ The root and category entry points are the convenient defaults. Concrete imports are useful when bundle analysis shows that a narrower entry point materially reduces the application bundle. Three.js, MapLibre, and Cesium remain separate optional packages and are not bundled unless the application imports them.
59
+
31
60
  ## Goal
32
61
 
33
62
  KChart의 새 public API는 class adapter가 아니라 class-free runtime입니다. UI에서는 `new BasicChart(...)` 같은 인스턴스를 직접 만들지 않고 `createKChart(...)`로 controller를 생성합니다.
@@ -646,6 +675,9 @@ const chart = createKChart<CityPoint>({
646
675
  markerColor: '#5db8ff',
647
676
  onMarkerClick: ({ data }) => {
648
677
  window.open(data.url, '_blank', 'noopener,noreferrer');
678
+ },
679
+ onMoveEnd: ({lon, lat, x, y}) => {
680
+ console.log('Globe center', {lon, lat, x, y});
649
681
  }
650
682
  })
651
683
  ]
@@ -654,6 +686,8 @@ const chart = createKChart<CityPoint>({
654
686
 
655
687
  `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 }`로 켜면 선택 좌표가 중앙에 오도록 지구본을 회전하고 확대합니다. `transition` 기본값은 `'warp'`입니다. 구름 전환은 `duration`으로 총 시간을 지정하거나 `coverDuration`과 `revealDuration`으로 덮이는 시간과 걷히는 시간을 각각 지정할 수 있습니다. `respectReducedMotion`의 기본값은 `true`이며 운영체제의 동작 줄이기 설정에서 최대 1.2초로 단축합니다. 지정한 시간을 항상 그대로 사용하려면 `respectReducedMotion: false`를 설정합니다. `color`, `density`, `blur`로 구름의 색상과 밀도를 조절할 수 있습니다. 기존 평면 지도 전환이 필요하면 `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을 적용할 수 있습니다.
656
688
 
689
+ `onMoveEnd`는 drag, pinch, wheel, zoom button으로 뷰가 실제 변경된 뒤 한 번 호출됩니다. context의 `x`, `y`는 drawable 중심 CSS pixel이고 `lon`, `lat`는 현재 globe 또는 drilldown map projection의 중심입니다. 초기 render, resize, marker drilldown 같은 애플리케이션 전환에는 호출되지 않습니다.
690
+
657
691
  실제 도로·건물 타일 지도가 필요한 경우 `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 등 별도 공급자에서 받아 장소 좌표 데이터로 전달해야 합니다.
658
692
 
659
693
  외부 장소 API 응답은 `parseMapLibrePlaces()`로 `id`, `name`, `lat`, `lon`을
@@ -908,6 +942,9 @@ createKChart<Region>({
908
942
  },
909
943
  tooltip: {
910
944
  formatter: ({label, value}) => `<strong>${label}</strong><br/>value: ${value}`
945
+ },
946
+ onMoveEnd: ({lon, lat}) => {
947
+ console.log('Map center', {lon, lat});
911
948
  }
912
949
  })
913
950
  ]
@@ -916,6 +953,8 @@ createKChart<Region>({
916
953
 
917
954
  `zoom`은 지역 지도 전용 확대/이동 옵션입니다. `enabled: true`이면 mouse wheel로 확대/축소하고 drag로 지도를 이동할 수 있습니다. `controls: {visible: true}`를 지정하면 오른쪽 상단에 `+`, 현재 배율, `-` 버튼이 표시됩니다. `scaleExtent`는 최소/최대 배율이며, `wheel`과 `pan`을 각각 꺼서 입력 방식을 제한할 수 있습니다. 지도 라벨은 비교적 좁은 화면에서 `callout` 선이 복잡해질 수 있으므로, 한국 시도 choropleth처럼 경계 내부에 값을 보여줄 때는 `labels.mode: 'centroid'`를 권장합니다.
918
955
 
956
+ `onMoveEnd`는 사용자 zoom/pan/button 조작으로 transform이 바뀐 경우에만 호출됩니다. `{lon, lat, x, y}`의 `x`, `y`는 drawable 중심 CSS pixel이며, `lon`, `lat`는 zoom transform을 역적용한 뒤 projection으로 역변환한 중심 좌표입니다.
957
+
919
958
  전세계 국가 지도는 `world-atlas` 110m country geometry를 내장한 `createWorldCountryMapSeries()`로 더 짧게 만들 수 있습니다. country 이름은 `world-atlas`의 `properties.name`과 맞춰야 합니다.
920
959
 
921
960
  ```ts
@@ -989,6 +1028,7 @@ createWorldCountryMapSeries<Country>({
989
1028
  - [World Activity Map StackBlitz](https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-world-activity-map?title=KChart%20World%20Activity%20Map&file=src/main.ts)
990
1029
  - [World Photo Marker Map StackBlitz](https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-world-photo-marker-map?title=KChart%20World%20Photo%20Marker%20Map&file=src/main.ts)
991
1030
  - [World Cluster Map StackBlitz](https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-world-cluster-map?title=KChart%20World%20Cluster%20Map&file=src/main.ts)
1031
+ - [Subcell Scalar Field StackBlitz](https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-subcell-heatmap-basic?title=KChart%20Subcell%20Heat%20Field&file=src/main.ts)
992
1032
 
993
1033
  ## Display Options
994
1034
 
@@ -1115,6 +1155,53 @@ Renderer context 주요 필드:
1115
1155
  - `getCanvas(name)`: Canvas 2D layer
1116
1156
  - `getWebglCanvas(name)`: WebGL canvas layer
1117
1157
 
1158
+ ### Custom Tooltip Hit Testing
1159
+
1160
+ A custom series can combine fields from its source datum and return application-specific tooltip HTML. The `tooltip(context)` callback receives the current data, resolved scales, and pointer coordinates; return `undefined` when no mark is hit.
1161
+
1162
+ ```ts
1163
+ type Point = {
1164
+ x: number;
1165
+ value: number;
1166
+ label: string;
1167
+ a: number;
1168
+ b: number;
1169
+ };
1170
+
1171
+ const stackedSeries = createCustomSeries<Point>({
1172
+ selector: 'stacked-column',
1173
+ displayName: 'Stacked Column',
1174
+ xField: 'x',
1175
+ yField: 'value',
1176
+ render({group, data, xScale, yScale}) {
1177
+ // Draw stacked rectangles with the chart scales.
1178
+ },
1179
+ tooltip({data, scales, mouseX}) {
1180
+ const xScale = scales.find((scale) => scale.field === 'x');
1181
+ const yScale = scales.find((scale) => scale.field === 'value');
1182
+ if (!xScale || !yScale) {
1183
+ return undefined;
1184
+ }
1185
+
1186
+ const hit = data.find((point) => {
1187
+ const x = xScale.scale(point.x);
1188
+ return Math.abs(mouseX - x) < 12;
1189
+ });
1190
+ if (!hit) {
1191
+ return undefined;
1192
+ }
1193
+
1194
+ return {
1195
+ data: hit,
1196
+ x: xScale.scale(hit.x),
1197
+ y: yScale.scale(hit.value),
1198
+ distance: 0,
1199
+ html: `<strong>${hit.label}</strong><br/>A: ${hit.a}<br/>B: ${hit.b}`
1200
+ };
1201
+ }
1202
+ });
1203
+ ```
1204
+
1118
1205
  ### Three.js renderer 연결
1119
1206
 
1120
1207
  Three.js 같은 외부 렌더링 엔진도 동일한 함수형 확장 지점을 사용합니다. KChart는
@@ -1,14 +1,66 @@
1
1
  # React And Next.js Guide
2
2
 
3
- KChart core package(`@keneth80/k-chart`)는 framework-agnostic 함수형 chart runtime입니다. 현재 npm으로 배포된 라이브러리 안에는 공식 React plugin package가 포함되어 있지 않습니다.
3
+ KChart core package(`@keneth80/k-chart`)는 framework-agnostic 함수형 chart runtime입니다. React 프로젝트에서는 별도 저장소와 npm package로 배포되는 공식 wrapper인 `@keneth80/k-chart-react`를 사용하는 것이 가장 빠른 경로입니다.
4
4
 
5
- 현재 React wrapper는 `kchart-next-playground` 저장소의 `packages/react/src`에 로컬 예제로 들어 있습니다. 이 문서는 React/Next.js 프로젝트에서 core API를 직접 쓰는 방법과, wrapper 컴포넌트를 만들어 재사용하는 방법을 설명합니다.
5
+ - npm: [@keneth80/k-chart-react](https://www.npmjs.com/package/@keneth80/k-chart-react)
6
+ - GitHub: [keneth80/k-chart-react](https://github.com/keneth80/k-chart-react)
6
7
 
7
- 복사해서 사용할 수 있는 wrapper 예제 파일도 제공합니다: [examples/react-wrapper.tsx](../examples/react-wrapper.tsx)
8
+ 공식 wrapper가 맞지 않는 경우에는 core API를 Client Component에서 직접 사용하거나 자체 wrapper를 만들 수 있습니다. 이 저장소의 대안 예제는 [examples/react-wrapper.tsx](../examples/react-wrapper.tsx)에 있습니다.
8
9
 
9
- ## Client Component에서 사용
10
+ ## 가장 빠른 방법: 공식 React Wrapper
10
11
 
11
- KChart는 DOM element, SVG, Canvas, WebGL layer를 직접 만들기 때문에 Next.js App Router에서는 반드시 Client Component 안에서 mount 이후 생성해야 합니다.
12
+ core package와 React wrapper를 함께 설치합니다. `react`와 `react-dom`은 wrapper의 peer dependency입니다.
13
+
14
+ ```bash
15
+ npm install @keneth80/k-chart @keneth80/k-chart-react
16
+ ```
17
+
18
+ Next.js App Router에서는 Client Component에서 사용합니다.
19
+
20
+ ```tsx
21
+ 'use client';
22
+
23
+ import { useMemo } from 'react';
24
+ import { createLineSeries } from '@keneth80/k-chart';
25
+ import { KChart } from '@keneth80/k-chart-react';
26
+
27
+ type Point = {
28
+ x: number;
29
+ value: number;
30
+ };
31
+
32
+ export function DashboardChart({ data }: { data: Point[] }) {
33
+ const series = useMemo(() => [
34
+ createLineSeries<Point>({
35
+ selector: 'value',
36
+ displayName: 'Value',
37
+ xField: 'x',
38
+ yField: 'value',
39
+ curve: true
40
+ })
41
+ ], []);
42
+
43
+ return (
44
+ <KChart<Point>
45
+ data={data}
46
+ axes={[
47
+ { field: 'x', type: 'number', placement: 'bottom', title: 'Index' },
48
+ { field: 'value', type: 'number', placement: 'left', title: 'Value' }
49
+ ]}
50
+ series={series}
51
+ grid={{ visible: true, y: true }}
52
+ tooltip={{ visible: true }}
53
+ style={{ width: '100%', height: 420 }}
54
+ />
55
+ );
56
+ }
57
+ ```
58
+
59
+ wrapper의 전체 props와 지원 범위는 [package README](https://github.com/keneth80/k-chart-react#readme)를 기준으로 확인하세요.
60
+
61
+ ## Core API를 직접 Client Component에서 사용
62
+
63
+ KChart는 DOM element, SVG, Canvas, WebGL layer를 직접 만들기 때문에 core API를 직접 쓸 때는 Next.js App Router의 Client Component 안에서 mount 이후 생성해야 합니다.
12
64
 
13
65
  ```tsx
14
66
  'use client';
@@ -71,9 +123,9 @@ export function TrafficChart({ data }: { data: TrafficPoint[] }) {
71
123
  }
72
124
  ```
73
125
 
74
- ## 재사용 가능한 React Wrapper
126
+ ## 자체 React Wrapper 만들기
75
127
 
76
- 여러 화면에서 같은 방식으로 차트를 쓴다면 wrapper 컴포넌트를 만들어두는 편이 좋습니다.
128
+ 공식 wrapper 대신 lifecycle이나 props contract를 직접 관리해야 한다면 자체 wrapper 컴포넌트를 만들 수 있습니다.
77
129
 
78
130
  전체 파일 예제: [examples/react-wrapper.tsx](../examples/react-wrapper.tsx)
79
131
 
@@ -221,12 +273,14 @@ Next.js 프로젝트에서 패키지 transpile이 필요하면 `next.config.mjs`
221
273
 
222
274
  ```js
223
275
  const nextConfig = {
224
- transpilePackages: ['@keneth80/k-chart']
276
+ transpilePackages: ['@keneth80/k-chart', '@keneth80/k-chart-react']
225
277
  };
226
278
 
227
279
  export default nextConfig;
228
280
  ```
229
281
 
282
+ core API만 직접 사용하는 프로젝트라면 `@keneth80/k-chart-react` 항목은 제외합니다.
283
+
230
284
  ## OffscreenCanvas Worker 사용
231
285
 
232
286
  `asyncRender`를 쓰는 경우 worker 파일은 client bundle에서 생성해야 합니다.
@@ -1,14 +1,22 @@
1
- # KChart Refactor Plan
1
+ # KChart Architecture Refactor Record
2
+
3
+ > Status: completed. This document records the class-free modularization that
4
+ > produced the current public runtime; it is not an active feature roadmap.
2
5
 
3
6
  ## Current Structure
4
7
 
5
8
  ```txt
6
9
  src/
7
10
  ├─ index.ts public export surface
8
- ├─ kchart.ts class-free chart runtime
9
- ├─ main.ts playground demo
10
- ├─ style.css playground and chart theme
11
- └─ types/ local asset/type declarations
11
+ ├─ kchart.ts compatibility barrel for functional imports
12
+ ├─ core/ contracts, state, scales, layers, and lifecycle
13
+ ├─ series/ SVG, Canvas, WebGL, and custom renderers
14
+ ├─ options/ guide lines, spec areas, navigator, and notes
15
+ ├─ presets/ simple chart factories and fluent builder
16
+ ├─ worker/ OffscreenCanvas worker entry
17
+ ├─ utils/ public renderer-independent algorithms
18
+ ├─ internal/ runtime implementation helpers
19
+ └─ ai/ chart planning schema and compiler
12
20
  ```
13
21
 
14
22
  ## Runtime Responsibility Split
@@ -38,24 +46,32 @@ import {
38
46
  } from '@keneth80/k-chart';
39
47
  ```
40
48
 
41
- `src/index.ts` exports only `src/kchart.ts`, so package consumers do not receive the old class-based API.
49
+ `src/index.ts` exports the supported functional root API. The `package.json`
50
+ exports map exposes documented category subpaths, while `src/kchart.ts`
51
+ preserves compatible functional imports. Legacy class implementations are not
52
+ part of the public package surface.
42
53
 
43
54
  ## Completed Migration
44
55
 
45
- 1. Added `src/kchart.ts` as the functional runtime.
46
- 2. Replaced the public package surface with KChart-only exports.
47
- 3. Replaced legacy playground entry with KChart examples.
48
- 4. Removed legacy class-based chart source from `src/component`.
49
- 5. Reduced package `files` so published tarballs include only KChart runtime output.
50
- 6. Reduced runtime dependencies to the D3 modules used by `src/kchart.ts`.
51
- 7. Added built-in Canvas 2D line and point renderer factories.
52
- 8. Added built-in WebGL point renderer factory.
53
- 9. Added title, grid, legend, and axis title display options.
54
- 10. Added basic nearest-point tooltip support.
55
-
56
- ## Remaining Roadmap
57
-
58
- 1. Add zoom/pan behavior as a runtime plugin.
59
- 2. Add richer tooltip modes, fixed tooltip positioning, and crosshair support.
60
- 3. Add built-in WebGL line renderer.
61
- 4. Add focused tests for scale resolution, resize, SVG line render, Canvas/WebGL renderers, tooltip, and custom renderer context.
56
+ 1. Replaced the legacy class implementation with `createKChart(...)` and
57
+ `KChartController`.
58
+ 2. Split runtime ownership into `core`, `series`, `options`, `presets`,
59
+ `worker`, `utils`, and `internal` modules.
60
+ 3. Added SVG, Canvas 2D, WebGL, and Custom Series renderers behind one series
61
+ contract.
62
+ 4. Added zoom/pan, tooltip and cursor modes, worker rendering, animation,
63
+ range navigation, and focused regression tests.
64
+ 5. Added simple preset factories while retaining direct composition for custom
65
+ visualization.
66
+ 6. Kept Three.js, Cesium, and MapLibre integrations in optional packages.
67
+
68
+ ## Ongoing Compatibility Principles
69
+
70
+ - Preserve documented functional root and subpath imports across compatible
71
+ releases.
72
+ - Keep renderer and optional-adapter dependencies isolated so consumers load
73
+ only the capabilities they use.
74
+ - Add behavior in the module that owns it and cover public contracts with
75
+ focused regression tests.
76
+ - Record future feature work in issues or release plans rather than in this
77
+ completed migration record.
package/docs/release.md CHANGED
@@ -13,21 +13,26 @@ KChart is published to npm as `@keneth80/k-chart`.
13
13
  Run these checks before every release:
14
14
 
15
15
  ```bash
16
- npm install
16
+ npm ci
17
+ npm run ci:adapters
17
18
  npm run typecheck
18
- npm run build:lib
19
+ npm run test:unit
20
+ npm run build-demo
19
21
  npm run pack:dry
20
22
  ```
21
23
 
22
- `npm run pack:dry` should show only the runtime package files:
24
+ `npm run pack:dry` should show the configured public package files:
23
25
 
24
26
  - `lib/**`
25
27
  - `README.md`
26
28
  - `LICENSE`
27
29
  - `CHANGELOG.md`
28
30
  - `package.json`
31
+ - `llms.txt` and `ai/**`
32
+ - selected `docs/**` guides and assets
33
+ - TypeScript integration examples and standalone `examples/stackblitz-*` projects
29
34
 
30
- It should not include `node_modules`, `src`, `dist`, demo files, webpack config, or local archives.
35
+ It should not include `node_modules`, `src`, `dist`, webpack config, or local archives.
31
36
 
32
37
  ## GitFlow
33
38