@keneth80/k-chart 1.26.0 → 1.27.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 +72 -0
- package/README.md +129 -1095
- package/docs/code-graph-handoff.md +19 -37
- package/docs/configuration-reference.md +8 -1
- package/docs/functional-api.md +77 -0
- package/docs/react-nextjs.md +62 -8
- package/docs/refactor-plan.md +39 -23
- package/docs/release.md +9 -4
- package/examples/stackblitz-calendar-heatmap-basic/index.html +37 -0
- package/examples/stackblitz-calendar-heatmap-basic/package-lock.json +1548 -0
- package/examples/stackblitz-calendar-heatmap-basic/package.json +18 -0
- package/examples/stackblitz-calendar-heatmap-basic/src/main.ts +172 -0
- package/examples/stackblitz-calendar-heatmap-basic/src/style.css +33 -0
- package/examples/stackblitz-calendar-heatmap-basic/src/vite-env.d.ts +1 -0
- package/examples/stackblitz-dual-axis-combo-basic/index.html +27 -0
- package/examples/stackblitz-dual-axis-combo-basic/package-lock.json +1548 -0
- package/examples/stackblitz-dual-axis-combo-basic/package.json +18 -0
- package/examples/stackblitz-dual-axis-combo-basic/src/main.ts +88 -0
- package/examples/stackblitz-dual-axis-combo-basic/src/style.css +31 -0
- package/examples/stackblitz-dual-axis-combo-basic/src/vite-env.d.ts +1 -0
- package/examples/stackblitz-hybrid-operations-dashboard/index.html +53 -0
- package/examples/stackblitz-hybrid-operations-dashboard/package-lock.json +1548 -0
- package/examples/stackblitz-hybrid-operations-dashboard/package.json +18 -0
- package/examples/stackblitz-hybrid-operations-dashboard/src/main.ts +181 -0
- package/examples/stackblitz-hybrid-operations-dashboard/src/style.css +52 -0
- package/examples/stackblitz-pareto-basic/index.html +22 -0
- package/examples/stackblitz-pareto-basic/package-lock.json +1548 -0
- package/examples/stackblitz-pareto-basic/package.json +18 -0
- package/examples/stackblitz-pareto-basic/src/main.ts +101 -0
- package/examples/stackblitz-pareto-basic/src/style.css +31 -0
- package/examples/stackblitz-pareto-basic/src/vite-env.d.ts +1 -0
- package/examples/stackblitz-simple-api-basic/package-lock.json +96 -4
- package/examples/stackblitz-simple-api-basic/package.json +1 -1
- package/examples/stackblitz-subcell-heatmap-basic/README.md +48 -0
- package/examples/stackblitz-subcell-heatmap-basic/index.html +13 -0
- package/examples/stackblitz-subcell-heatmap-basic/package-lock.json +1788 -0
- package/examples/stackblitz-subcell-heatmap-basic/package.json +23 -0
- package/examples/stackblitz-subcell-heatmap-basic/src/app.ts +212 -0
- package/examples/stackblitz-subcell-heatmap-basic/src/component.css +169 -0
- package/examples/stackblitz-subcell-heatmap-basic/src/heatmap-demo-core.ts +505 -0
- package/examples/stackblitz-subcell-heatmap-basic/src/heatmap-demo.ts +23 -0
- package/examples/stackblitz-subcell-heatmap-basic/src/main.ts +15 -0
- package/examples/stackblitz-subcell-heatmap-basic/src/maplibre-compat.ts +6 -0
- package/examples/stackblitz-subcell-heatmap-basic/src/model.ts +242 -0
- package/examples/stackblitz-subcell-heatmap-basic/src/raster.ts +121 -0
- package/examples/stackblitz-subcell-heatmap-basic/src/style.css +15 -0
- package/examples/stackblitz-subcell-heatmap-basic/src/synthetic.ts +72 -0
- package/examples/stackblitz-subcell-heatmap-basic/src/vendor.d.ts +3 -0
- package/examples/stackblitz-subcell-heatmap-basic/src/vite-env.d.ts +1 -0
- package/examples/stackblitz-topology-basic/package-lock.json +96 -4
- package/examples/stackblitz-topology-basic/package.json +1 -1
- package/examples/stackblitz-us-transport-route/index.html +29 -0
- package/examples/stackblitz-us-transport-route/package.json +17 -0
- package/examples/stackblitz-us-transport-route/src/main.ts +211 -0
- package/examples/stackblitz-us-transport-route/src/style.css +178 -0
- package/examples/stackblitz-webgl-line-basic/package-lock.json +96 -4
- package/examples/stackblitz-webgl-line-basic/package.json +1 -1
- package/examples/stackblitz-world-activity-map/package.json +1 -1
- package/lib/core/contracts.d.ts +6 -2
- package/lib/core/contracts.d.ts.map +1 -1
- package/lib/series/svg-graph.d.ts +29 -0
- package/lib/series/svg-graph.d.ts.map +1 -1
- package/lib/series/svg-graph.js +509 -80
- package/lib/series/svg-graph.js.map +1 -1
- package/package.json +1 -1
|
@@ -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.
|
|
10
|
-
- Current integration branch at handoff: `
|
|
11
|
-
- Release tag: `v1.
|
|
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.
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
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
|
|
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/
|
|
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/
|
|
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 | `
|
|
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`:
|
|
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
|
-
-
|
|
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
|
-
|
|
293
|
-
|
|
294
|
-
|
|
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`
|
package/docs/functional-api.md
CHANGED
|
@@ -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를 생성합니다.
|
|
@@ -989,6 +1018,7 @@ createWorldCountryMapSeries<Country>({
|
|
|
989
1018
|
- [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
1019
|
- [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
1020
|
- [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)
|
|
1021
|
+
- [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
1022
|
|
|
993
1023
|
## Display Options
|
|
994
1024
|
|
|
@@ -1115,6 +1145,53 @@ Renderer context 주요 필드:
|
|
|
1115
1145
|
- `getCanvas(name)`: Canvas 2D layer
|
|
1116
1146
|
- `getWebglCanvas(name)`: WebGL canvas layer
|
|
1117
1147
|
|
|
1148
|
+
### Custom Tooltip Hit Testing
|
|
1149
|
+
|
|
1150
|
+
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.
|
|
1151
|
+
|
|
1152
|
+
```ts
|
|
1153
|
+
type Point = {
|
|
1154
|
+
x: number;
|
|
1155
|
+
value: number;
|
|
1156
|
+
label: string;
|
|
1157
|
+
a: number;
|
|
1158
|
+
b: number;
|
|
1159
|
+
};
|
|
1160
|
+
|
|
1161
|
+
const stackedSeries = createCustomSeries<Point>({
|
|
1162
|
+
selector: 'stacked-column',
|
|
1163
|
+
displayName: 'Stacked Column',
|
|
1164
|
+
xField: 'x',
|
|
1165
|
+
yField: 'value',
|
|
1166
|
+
render({group, data, xScale, yScale}) {
|
|
1167
|
+
// Draw stacked rectangles with the chart scales.
|
|
1168
|
+
},
|
|
1169
|
+
tooltip({data, scales, mouseX}) {
|
|
1170
|
+
const xScale = scales.find((scale) => scale.field === 'x');
|
|
1171
|
+
const yScale = scales.find((scale) => scale.field === 'value');
|
|
1172
|
+
if (!xScale || !yScale) {
|
|
1173
|
+
return undefined;
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
const hit = data.find((point) => {
|
|
1177
|
+
const x = xScale.scale(point.x);
|
|
1178
|
+
return Math.abs(mouseX - x) < 12;
|
|
1179
|
+
});
|
|
1180
|
+
if (!hit) {
|
|
1181
|
+
return undefined;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
return {
|
|
1185
|
+
data: hit,
|
|
1186
|
+
x: xScale.scale(hit.x),
|
|
1187
|
+
y: yScale.scale(hit.value),
|
|
1188
|
+
distance: 0,
|
|
1189
|
+
html: `<strong>${hit.label}</strong><br/>A: ${hit.a}<br/>B: ${hit.b}`
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1192
|
+
});
|
|
1193
|
+
```
|
|
1194
|
+
|
|
1118
1195
|
### Three.js renderer 연결
|
|
1119
1196
|
|
|
1120
1197
|
Three.js 같은 외부 렌더링 엔진도 동일한 함수형 확장 지점을 사용합니다. KChart는
|
package/docs/react-nextjs.md
CHANGED
|
@@ -1,14 +1,66 @@
|
|
|
1
1
|
# React And Next.js Guide
|
|
2
2
|
|
|
3
|
-
KChart core package(`@keneth80/k-chart`)는 framework-agnostic 함수형 chart runtime입니다.
|
|
3
|
+
KChart core package(`@keneth80/k-chart`)는 framework-agnostic 함수형 chart runtime입니다. React 프로젝트에서는 별도 저장소와 npm package로 배포되는 공식 wrapper인 `@keneth80/k-chart-react`를 사용하는 것이 가장 빠른 경로입니다.
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
|
|
8
|
+
공식 wrapper가 맞지 않는 경우에는 core API를 Client Component에서 직접 사용하거나 자체 wrapper를 만들 수 있습니다. 이 저장소의 대안 예제는 [examples/react-wrapper.tsx](../examples/react-wrapper.tsx)에 있습니다.
|
|
8
9
|
|
|
9
|
-
##
|
|
10
|
+
## 가장 빠른 방법: 공식 React Wrapper
|
|
10
11
|
|
|
11
|
-
|
|
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
|
-
##
|
|
126
|
+
## 자체 React Wrapper 만들기
|
|
75
127
|
|
|
76
|
-
|
|
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에서 생성해야 합니다.
|
package/docs/refactor-plan.md
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
# KChart Refactor
|
|
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
|
|
9
|
-
├─
|
|
10
|
-
├─
|
|
11
|
-
|
|
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
|
|
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.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
|
16
|
+
npm ci
|
|
17
|
+
npm run ci:adapters
|
|
17
18
|
npm run typecheck
|
|
18
|
-
npm run
|
|
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
|
|
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`,
|
|
35
|
+
It should not include `node_modules`, `src`, `dist`, webpack config, or local archives.
|
|
31
36
|
|
|
32
37
|
## GitFlow
|
|
33
38
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>KChart Calendar Heatmap Basic</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<main class="calendar-shell">
|
|
10
|
+
<header class="calendar-header">
|
|
11
|
+
<div>
|
|
12
|
+
<p class="eyebrow">Service operations</p>
|
|
13
|
+
<h1>Daily support demand</h1>
|
|
14
|
+
<p>New customer cases opened across the first half of 2026.</p>
|
|
15
|
+
</div>
|
|
16
|
+
<div class="summary" aria-label="Half-year case summary">
|
|
17
|
+
<span>H1 total</span>
|
|
18
|
+
<strong id="case-total">0</strong>
|
|
19
|
+
<small>cases opened</small>
|
|
20
|
+
</div>
|
|
21
|
+
</header>
|
|
22
|
+
<section class="chart-panel" aria-label="Calendar heatmap of daily support cases">
|
|
23
|
+
<div class="heat-legend" aria-label="Cases opened color scale">
|
|
24
|
+
<span>Fewer</span>
|
|
25
|
+
<i style="--swatch:#e9f3ef"></i>
|
|
26
|
+
<i style="--swatch:#bddfd4"></i>
|
|
27
|
+
<i style="--swatch:#79bcae"></i>
|
|
28
|
+
<i style="--swatch:#348a80"></i>
|
|
29
|
+
<i style="--swatch:#075b5a"></i>
|
|
30
|
+
<span>More</span>
|
|
31
|
+
</div>
|
|
32
|
+
<div id="chart" role="img" aria-label="Week columns and weekday rows colored by daily support cases"></div>
|
|
33
|
+
</section>
|
|
34
|
+
</main>
|
|
35
|
+
<script type="module" src="/src/main.ts"></script>
|
|
36
|
+
</body>
|
|
37
|
+
</html>
|