@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.
- package/CHANGELOG.md +79 -0
- package/README.md +131 -1100
- package/docs/code-graph-handoff.md +19 -37
- package/docs/configuration-reference.md +16 -1
- package/docs/functional-api.md +87 -0
- package/docs/react-nextjs.md +62 -8
- package/docs/refactor-plan.md +39 -23
- package/docs/release.md +9 -4
- 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-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 +14 -2
- package/lib/core/contracts.d.ts.map +1 -1
- package/lib/internal/map-move-end.d.ts +8 -0
- package/lib/internal/map-move-end.d.ts.map +1 -0
- package/lib/internal/map-move-end.js +33 -0
- package/lib/internal/map-move-end.js.map +1 -0
- package/lib/series/svg-globe.d.ts.map +1 -1
- package/lib/series/svg-globe.js +66 -8
- package/lib/series/svg-globe.js.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/lib/series/svg-region-map.d.ts.map +1 -1
- package/lib/series/svg-region-map.js +72 -1
- package/lib/series/svg-region-map.js.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,36 +1,23 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<img src="docs/assets/kchart-icon.svg" alt="KChart icon" width="96" height="96" />
|
|
3
|
-
<br />
|
|
4
|
-
<img src="docs/assets/kchart-hero.svg" alt="KChart hybrid chart runtime preview" width="100%" />
|
|
5
3
|
</p>
|
|
6
4
|
|
|
7
5
|
<h1 align="center">KChart</h1>
|
|
8
6
|
|
|
9
7
|
<p align="center">
|
|
10
|
-
TypeScript
|
|
11
|
-
|
|
8
|
+
<strong>TypeScript chart runtime combining SVG, Canvas, and WebGL for custom and large-data visualization.</strong><br />
|
|
9
|
+
하나의 class-free 코어에서 표준 차트, 대용량 데이터, 직접 만든 renderer를 같은 축과 scale 위에 조합합니다.
|
|
12
10
|
</p>
|
|
13
11
|
|
|
14
12
|
<p align="center">
|
|
15
|
-
<a href="https://github.com/keneth80/k-chart/releases"><img alt="Release" src="https://img.shields.io/github/v/release/keneth80/k-chart?include_prereleases&style=for-the-badge&label=Release&color=38bdf8"></a>
|
|
16
|
-
<a href="https://github.com/keneth80/k-chart/actions/workflows/ci.yml"><img alt="Build" src="https://img.shields.io/github/actions/workflow/status/keneth80/k-chart/ci.yml?branch=main&style=for-the-badge&label=Build"></a>
|
|
17
|
-
<img alt="Coverage" src="https://img.shields.io/badge/Coverage-not_configured-64748b?style=for-the-badge">
|
|
18
13
|
<a href="https://www.npmjs.com/package/@keneth80/k-chart"><img alt="npm" src="https://img.shields.io/npm/v/%40keneth80%2Fk-chart?style=for-the-badge&label=npm&color=0ea5e9"></a>
|
|
14
|
+
<a href="https://github.com/keneth80/k-chart/actions/workflows/ci.yml"><img alt="Build" src="https://img.shields.io/github/actions/workflow/status/keneth80/k-chart/ci.yml?branch=main&style=for-the-badge&label=Build"></a>
|
|
19
15
|
<a href="https://github.com/keneth80/k-chart/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/github/license/keneth80/k-chart?style=for-the-badge&color=22c55e"></a>
|
|
20
|
-
<a href="https://k-chart
|
|
16
|
+
<a href="https://github.com/keneth80/k-chart/releases"><img alt="Release" src="https://img.shields.io/github/v/release/keneth80/k-chart?include_prereleases&style=for-the-badge&label=Release&color=38bdf8"></a>
|
|
21
17
|
</p>
|
|
22
18
|
|
|
23
19
|
<p align="center">
|
|
24
|
-
<code>SVG</code>
|
|
25
|
-
<code>Canvas 2D</code>
|
|
26
|
-
<code>WebGL</code>
|
|
27
|
-
<code>Three.js</code>
|
|
28
|
-
<code>CesiumJS</code>
|
|
29
|
-
<code>MapLibre</code>
|
|
30
|
-
<code>Candlestick</code>
|
|
31
|
-
<code>LTTB</code>
|
|
32
|
-
<code>OffscreenCanvas</code>
|
|
33
|
-
<code>Tooltip Notes</code>
|
|
20
|
+
<code>SVG</code> · <code>Canvas 2D</code> · <code>WebGL</code> · <code>Custom Series</code>
|
|
34
21
|
</p>
|
|
35
22
|
|
|
36
23
|
<p align="center">
|
|
@@ -38,213 +25,23 @@
|
|
|
38
25
|
·
|
|
39
26
|
<a href="#quick-start"><strong>Quick Start</strong></a>
|
|
40
27
|
·
|
|
41
|
-
<a href="
|
|
42
|
-
·
|
|
43
|
-
<a href="docs/ai/index.md"><strong>AI & Agent Guide</strong></a>
|
|
44
|
-
·
|
|
45
|
-
<a href="llms.txt"><strong>llms.txt</strong></a>
|
|
46
|
-
·
|
|
47
|
-
<a href="packages/k-chart-three/README.md"><strong>Three.js Adapter</strong></a>
|
|
48
|
-
</p>
|
|
49
|
-
|
|
50
|
-
<p align="center">
|
|
51
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-line-basic?title=KChart%20Line%20Basic&file=src/main.ts">
|
|
52
|
-
<img alt="Open SVG Line in StackBlitz" src="https://developer.stackblitz.com/img/open_in_stackblitz.svg">
|
|
53
|
-
</a>
|
|
54
|
-
<br />
|
|
55
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-simple-api-basic?title=KChart%20Simple%20API&file=src/main.ts"><strong>Simple API</strong></a>
|
|
56
|
-
·
|
|
57
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-canvas-line-basic?title=KChart%20Canvas%20Line&file=src/main.ts"><strong>Canvas Line</strong></a>
|
|
58
|
-
·
|
|
59
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-webgl-line-basic?title=KChart%20WebGL%20Line&file=src/main.ts"><strong>WebGL Line</strong></a>
|
|
60
|
-
·
|
|
61
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-realtime-line-basic?title=KChart%20Realtime%20Line&file=src/main.ts"><strong>Realtime Line</strong></a>
|
|
62
|
-
·
|
|
63
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-worker-json-line?title=KChart%20Worker%20JSON%20Line&file=src/main.ts"><strong>Worker JSON</strong></a>
|
|
64
|
-
·
|
|
65
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-korea-region-map-basic?title=KChart%20Korea%20Region%20Map&file=src/main.ts"><strong>Korea Map</strong></a>
|
|
66
|
-
·
|
|
67
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-world-country-map-basic?title=KChart%20World%20Country%20Map&file=src/main.ts"><strong>World Map</strong></a>
|
|
68
|
-
·
|
|
69
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-world-activity-map?title=KChart%20World%20Activity%20Map&file=src/main.ts"><strong>World Activity Map</strong></a>
|
|
70
|
-
·
|
|
71
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-world-cluster-map?title=KChart%20World%20Cluster%20Map&file=src/main.ts"><strong>World Cluster Map</strong></a>
|
|
72
|
-
·
|
|
73
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-column-basic?title=KChart%20Column&file=src/main.ts"><strong>Column</strong></a>
|
|
74
|
-
·
|
|
75
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-stacked-column-basic?title=KChart%20Stacked%20Column&file=src/main.ts"><strong>Stacked Column</strong></a>
|
|
76
|
-
·
|
|
77
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-dual-axis-combo-basic?title=KChart%20Dual-axis%20Combo&file=src/main.ts"><strong>Dual-axis Combo</strong></a>
|
|
78
|
-
·
|
|
79
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-pareto-basic?title=KChart%20Pareto&file=src/main.ts"><strong>Pareto</strong></a>
|
|
80
|
-
·
|
|
81
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-calendar-heatmap-basic?title=KChart%20Calendar%20Heatmap&file=src/main.ts"><strong>Calendar Heatmap</strong></a>
|
|
28
|
+
<a href="https://www.npmjs.com/package/@keneth80/k-chart"><strong>npm</strong></a>
|
|
82
29
|
·
|
|
83
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-
|
|
84
|
-
·
|
|
85
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-plot-basic?title=KChart%20Plot&file=src/main.ts"><strong>Plot</strong></a>
|
|
86
|
-
·
|
|
87
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-radial-basic?title=KChart%20Radial&file=src/main.ts"><strong>Radial</strong></a>
|
|
88
|
-
·
|
|
89
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-pie-basic?title=KChart%20Pie&file=src/main.ts"><strong>Pie</strong></a>
|
|
90
|
-
·
|
|
91
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-doughnut-basic?title=KChart%20Doughnut&file=src/main.ts"><strong>Doughnut</strong></a>
|
|
92
|
-
·
|
|
93
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-doughnut-scroll-legend?title=KChart%20Scrollable%20Doughnut%20Legend&file=src/main.ts"><strong>Scrollable Doughnut Legend</strong></a>
|
|
94
|
-
·
|
|
95
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-multi-series-basic?title=KChart%20Multi%20Series&file=src/main.ts"><strong>Multi Series</strong></a>
|
|
96
|
-
·
|
|
97
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-options-basic?title=KChart%20Options&file=src/main.ts"><strong>Options</strong></a>
|
|
98
|
-
·
|
|
99
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-topology-basic?title=KChart%20Topology&file=src/main.ts"><strong>Topology</strong></a>
|
|
100
|
-
·
|
|
101
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-graph-basic?title=KChart%20Graph%20Chart&file=src/main.ts"><strong>Graph Chart</strong></a>
|
|
102
|
-
·
|
|
103
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-tree-basic?title=KChart%20Tree%20Chart&file=src/main.ts"><strong>Tree Chart</strong></a>
|
|
104
|
-
·
|
|
105
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-treemap-basic?title=KChart%20Treemap&file=src/main.ts"><strong>Treemap</strong></a>
|
|
106
|
-
·
|
|
107
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-sankey-basic?title=KChart%20Sankey%20Flow&file=src/main.ts"><strong>Sankey</strong></a>
|
|
108
|
-
·
|
|
109
|
-
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-three-wafer-basic?title=KChart%20Three.js%20Wafer&file=src/main.ts"><strong>Three.js Wafer</strong></a>
|
|
110
|
-
</p>
|
|
111
|
-
|
|
112
|
-
## Hybrid Rendering In 60 Seconds
|
|
113
|
-
|
|
114
|
-
<p align="center">
|
|
115
|
-
<a href="https://raw.githubusercontent.com/keneth80/k-chart/main/docs/promotion/kchart-hybrid-rendering-60s-ko.mp4">
|
|
116
|
-
<img src="docs/promotion/kchart-hybrid-rendering-preview.gif" alt="Watch the KChart hybrid rendering video" width="100%" />
|
|
117
|
-
</a>
|
|
30
|
+
<a href="https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-simple-api-basic?title=KChart%20Simple%20API&file=src/main.ts"><strong>Run in StackBlitz</strong></a>
|
|
118
31
|
</p>
|
|
119
32
|
|
|
120
33
|
<p align="center">
|
|
121
|
-
<
|
|
122
|
-
·
|
|
123
|
-
<a href="docs/promotion/hybrid-rendering-ko.md"><strong>Read the Korean technical article</strong></a>
|
|
34
|
+
<img src="docs/assets/kchart-hero.svg" alt="KChart hybrid chart runtime preview" width="920" />
|
|
124
35
|
</p>
|
|
125
36
|
|
|
126
|
-
##
|
|
37
|
+
## Why KChart?
|
|
127
38
|
|
|
128
|
-
|
|
39
|
+
- **Hybrid rendering**: SVG, Canvas, and WebGL series share one chart runtime, layout, axes, and scales.
|
|
40
|
+
- **Large-data visualization**: WebGL renderers, pixel-column min/max or LTTB downsampling, and optional worker rendering keep dense line and point views practical.
|
|
41
|
+
- **Custom visualization**: `createCustomSeries(...)` exposes resolved scales, plot geometry, and drawing layers without requiring class inheritance.
|
|
42
|
+
- **Optional integrations**: React, Three.js, MapLibre, and Cesium live in separate packages or guides, so the core package stays focused.
|
|
129
43
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
## Why KChart
|
|
133
|
-
|
|
134
|
-
KChart는 완성형 대시보드 차트만 제공하는 라이브러리라기보다, 업무 화면에서 필요한 시각화를 가볍게 조립하기 위한 rendering runtime입니다. 축과 scale은 코어가 책임지고, series와 option은 함수형 renderer로 분리되어 SVG, Canvas, WebGL, Three.js, CesiumJS, MapLibre 같은 표현 계층을 필요할 때만 붙일 수 있습니다.
|
|
135
|
-
|
|
136
|
-
| Focus | KChart approach |
|
|
137
|
-
| --- | --- |
|
|
138
|
-
| Hybrid rendering | 하나의 chart runtime에서 SVG, Canvas 2D, WebGL series를 함께 사용할 수 있습니다. |
|
|
139
|
-
| Large data | WebGL line/point, interleaved buffer, LTTB downsampling, OffscreenCanvas worker hook을 제공합니다. |
|
|
140
|
-
| Custom visualization | `createCustomSeries(...)`로 scale, layer, plot size를 받은 뒤 원하는 renderer를 직접 구현할 수 있습니다. |
|
|
141
|
-
| Optional adapters | Three.js, CesiumJS, MapLibre는 별도 package로 분리해 기본 chart bundle에 3D/map 비용을 섞지 않습니다. |
|
|
142
|
-
| Business UI fit | tooltip note, fixed guide line, spec area, topology, candlestick처럼 운영 화면에서 바로 쓰는 옵션을 포함합니다. |
|
|
143
|
-
| Relationship analysis | `createGraphSeries(...)`로 source-target-metric 데이터를 Force/Circular 관계망으로 표현합니다. |
|
|
144
|
-
| Hierarchy analysis | `createTreeSeries(...)`로 id-parent 행을 조직도, 분류 체계, 의존 구조 형태로 표현합니다. |
|
|
145
|
-
| Part-to-whole analysis | `createTreemapSeries(...)`로 동일 metric의 구성 비중을 사각형 면적으로 비교합니다. |
|
|
146
|
-
| Flow analysis | `createSankeySeries(...)`로 단계별 흐름의 상대적인 크기와 이탈 지점을 표현합니다. |
|
|
147
|
-
|
|
148
|
-
### Performance Positioning
|
|
149
|
-
|
|
150
|
-
KChart의 성능 방향은 “모든 기능을 하나의 거대한 chart object에 넣기”가 아니라, 데이터 양과 표현 방식에 맞춰 renderer를 선택하는 것입니다.
|
|
151
|
-
|
|
152
|
-
- 작은 데이터와 선명한 DOM interaction이 필요하면 SVG series를 사용합니다.
|
|
153
|
-
- 수천에서 수만 개의 point를 빠르게 그려야 하면 Canvas series를 사용합니다.
|
|
154
|
-
- 더 큰 line/point 데이터나 잦은 viewport 변경이 있으면 WebGL series와 LTTB downsampling을 조합합니다.
|
|
155
|
-
- 3D, 지도, 지구본은 optional adapter package로 분리해 필요한 화면에서만 로드합니다.
|
|
156
|
-
|
|
157
|
-
## Core Concept
|
|
158
|
-
|
|
159
|
-
```txt
|
|
160
|
-
createKChart(config)
|
|
161
|
-
├─ axes -> scales
|
|
162
|
-
├─ svg/canvas/webgl layers
|
|
163
|
-
└─ series[]
|
|
164
|
-
├─ createLineSeries(...)
|
|
165
|
-
├─ createCanvasLineSeries(...)
|
|
166
|
-
├─ createCanvasPointSeries(...)
|
|
167
|
-
├─ createCanvasCandlestickSeries(...)
|
|
168
|
-
├─ createWebglLineSeries(...)
|
|
169
|
-
├─ createWebglPointSeries(...)
|
|
170
|
-
└─ createCustomSeries({ render(context) })
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
- `createKChart(...)`는 class 없이 plain runtime state와 controller를 만듭니다.
|
|
174
|
-
- `createLineSeries(...)`는 SVG line renderer를 함수형 series로 생성합니다.
|
|
175
|
-
- `createCanvasLineSeries(...)`, `createCanvasPointSeries(...)`는 Canvas 2D renderer를 함수형 series로 생성합니다.
|
|
176
|
-
- `createCanvasCandlestickSeries(...)`는 OHLC 데이터를 Canvas 2D 캔들차트로 렌더링합니다.
|
|
177
|
-
- `createWebglLineSeries(...)`는 대용량 line renderer를 WebGL `LINE_STRIP` 기반 함수형 series로 생성합니다.
|
|
178
|
-
- `createWebglPointSeries(...)`는 WebGL point renderer를 함수형 series로 생성합니다.
|
|
179
|
-
- `createCustomSeries(...)`는 renderer 함수를 그대로 series로 사용합니다.
|
|
180
|
-
- `render(context)`는 `group`, `data`, `scales`, `xScale`, `yScale`, `plotSize`, `color`, `getCanvas`, `getWebglCanvas`를 받습니다.
|
|
181
|
-
- Canvas/WebGL 시각화도 renderer 안에서 필요한 layer를 받아 직접 그릴 수 있습니다.
|
|
182
|
-
|
|
183
|
-
### Three.js Custom Series
|
|
184
|
-
|
|
185
|
-
Three.js는 KChart 코어 의존성이 아닙니다. 가벼운 3D scene wrapper와
|
|
186
|
-
반도체 웨이퍼 모니터링 객체가 필요하면 optional package인
|
|
187
|
-
`@keneth80/k-chart-three`를 설치합니다. 직접 renderer를 만들고 싶다면
|
|
188
|
-
`createCustomSeries(...)`와 `getWebglCanvas()`를 사용해 선택적으로 결합할 수도 있습니다.
|
|
189
|
-
|
|
190
|
-
```bash
|
|
191
|
-
npm install @keneth80/k-chart-three three
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
[`packages/k-chart-three`](packages/k-chart-three/README.md)는 renderer, camera,
|
|
195
|
-
OrbitControls, resize, pointer event, dispose 생명주기를 처리하는
|
|
196
|
-
`createKThreeScene(...)` wrapper를 제공합니다. `createThreeWaferSeries(...)`는
|
|
197
|
-
KChart series contract에 맞춘 웨이퍼 모니터링 예제이며, die cell은
|
|
198
|
-
`InstancedMesh`로 렌더링합니다.
|
|
199
|
-
|
|
200
|
-
```ts
|
|
201
|
-
import { createThreeWaferSeries, createWaferDies } from '@keneth80/k-chart-three';
|
|
202
|
-
import '@keneth80/k-chart-three/style.css';
|
|
203
|
-
|
|
204
|
-
const chart = createKChart({
|
|
205
|
-
selector: '#chart',
|
|
206
|
-
data: createWaferDies({ rows: 29, cols: 29 }),
|
|
207
|
-
axes: [],
|
|
208
|
-
grid: { visible: false },
|
|
209
|
-
legend: { visible: false },
|
|
210
|
-
series: [
|
|
211
|
-
createThreeWaferSeries({
|
|
212
|
-
selector: 'wafer-a17',
|
|
213
|
-
fields: {
|
|
214
|
-
id: 'id',
|
|
215
|
-
row: 'row',
|
|
216
|
-
col: 'col',
|
|
217
|
-
status: 'status',
|
|
218
|
-
value: 'value',
|
|
219
|
-
label: 'label'
|
|
220
|
-
}
|
|
221
|
-
})
|
|
222
|
-
]
|
|
223
|
-
});
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
양자리의 실제 주요 별 배치를 기반으로 별 노드와 연결선을 3D로 표현하는 전체 예제는
|
|
227
|
-
[`examples/three-constellation-series.ts`](examples/three-constellation-series.ts)에 있습니다.
|
|
228
|
-
|
|
229
|
-
```ts
|
|
230
|
-
const constellation = createThreeConstellationSeries({
|
|
231
|
-
selector: 'aries',
|
|
232
|
-
idField: 'id',
|
|
233
|
-
labelField: 'label',
|
|
234
|
-
xField: 'x',
|
|
235
|
-
yField: 'y',
|
|
236
|
-
zField: 'z',
|
|
237
|
-
sizeField: 'size',
|
|
238
|
-
colorField: 'color',
|
|
239
|
-
links: [
|
|
240
|
-
{ source: 'mesarthim', target: 'sheratan' },
|
|
241
|
-
{ source: 'sheratan', target: 'hamal' }
|
|
242
|
-
]
|
|
243
|
-
});
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
예제는 기존 KChart WebGL canvas를 Three.js renderer에 주입하고, `InstancedMesh`,
|
|
247
|
-
`LineSegments`, `OrbitControls`, `Raycaster`, resize 및 dispose 생명주기를 처리합니다.
|
|
44
|
+
Choose SVG for standard charts and DOM interaction, Canvas or WebGL for denser data, and Custom Series when the visualization itself is domain-specific.
|
|
248
45
|
|
|
249
46
|
## Install
|
|
250
47
|
|
|
@@ -252,959 +49,193 @@ const constellation = createThreeConstellationSeries({
|
|
|
252
49
|
npm install @keneth80/k-chart
|
|
253
50
|
```
|
|
254
51
|
|
|
255
|
-
##
|
|
256
|
-
|
|
257
|
-
- Live playground: [https://k-chart-playground.vercel.app/](https://k-chart-playground.vercel.app/)
|
|
258
|
-
|
|
259
|
-
The deployed playground demonstrates the React wrapper, chart examples, and configuration editor.
|
|
260
|
-
|
|
261
|
-
## Local Development
|
|
262
|
-
|
|
263
|
-
```bash
|
|
264
|
-
npm install
|
|
265
|
-
npm run build
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
Demo:
|
|
269
|
-
|
|
270
|
-
```bash
|
|
271
|
-
npm run dev
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
Then open `http://127.0.0.1:9003/`.
|
|
275
|
-
|
|
276
|
-
## Guides
|
|
277
|
-
|
|
278
|
-
- [Functional API Guide](docs/functional-api.md)
|
|
279
|
-
- [Configuration Reference](docs/configuration-reference.md)
|
|
280
|
-
- [Code Graph Handoff](docs/code-graph-handoff.md)
|
|
281
|
-
- [React And Next.js Guide](docs/react-nextjs.md)
|
|
282
|
-
- [Release Guide](docs/release.md)
|
|
283
|
-
- [React Wrapper Example](examples/react-wrapper.tsx)
|
|
284
|
-
- [Canvas Candlestick Example](examples/canvas-candlestick-series.ts)
|
|
285
|
-
- [SVG Globe Map Example](examples/svg-globe-map-series.ts)
|
|
286
|
-
- [MapLibre Globe Drilldown Adapter](packages/k-chart-maplibre/README.md)
|
|
287
|
-
- [CesiumJS 3D Route Adapter](packages/k-chart-cesium/README.md)
|
|
288
|
-
- [Three.js Scene And Wafer Adapter](packages/k-chart-three/README.md)
|
|
289
|
-
|
|
290
|
-
## Module Structure
|
|
291
|
-
|
|
292
|
-
KChart keeps its public root API compatible while separating implementation by
|
|
293
|
-
responsibility:
|
|
294
|
-
|
|
295
|
-
```text
|
|
296
|
-
src/
|
|
297
|
-
├── core/ # contracts, state, layers, scales, and chart lifecycle
|
|
298
|
-
├── series/ # SVG, Canvas, WebGL, candlestick, and globe renderers
|
|
299
|
-
├── options/ # spec area, guide/cursor line, range navigator, and tooltip notes
|
|
300
|
-
├── worker/ # OffscreenCanvas worker entry
|
|
301
|
-
└── utils/ # renderer-independent algorithms such as LTTB
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
Existing root imports continue to work. Explicit subpath imports are also
|
|
305
|
-
available:
|
|
306
|
-
|
|
307
|
-
```ts
|
|
308
|
-
import {createKChart} from '@keneth80/k-chart/core';
|
|
309
|
-
import {createLineChart, chartConfig} from '@keneth80/k-chart/presets';
|
|
310
|
-
import {createCanvasLineSeries} from '@keneth80/k-chart/series';
|
|
311
|
-
import {createGuideLineOption} from '@keneth80/k-chart/options';
|
|
312
|
-
import {downsampleLTTB} from '@keneth80/k-chart/utils';
|
|
313
|
-
import {startKChartRenderWorker} from '@keneth80/k-chart/worker';
|
|
314
|
-
```
|
|
52
|
+
## Quick Start
|
|
315
53
|
|
|
316
|
-
|
|
317
|
-
to avoid bundling unrelated charts and map data:
|
|
54
|
+
Add a container:
|
|
318
55
|
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
import type {
|
|
322
|
-
KChartAxis,
|
|
323
|
-
KChartController,
|
|
324
|
-
KChartSeries
|
|
325
|
-
} from '@keneth80/k-chart/core/contracts';
|
|
326
|
-
import {createLineSeries} from '@keneth80/k-chart/series/svg-line';
|
|
327
|
-
import {createCanvasLineSeries} from '@keneth80/k-chart/series/canvas-line';
|
|
328
|
-
import {createWebglLineSeries} from '@keneth80/k-chart/series/webgl-line';
|
|
56
|
+
```html
|
|
57
|
+
<div id="chart" style="width: 100%; height: 420px"></div>
|
|
329
58
|
```
|
|
330
59
|
|
|
331
|
-
|
|
332
|
-
size. Use concrete module entry points in plugins and embedded applications
|
|
333
|
-
where only a known renderer subset is needed.
|
|
334
|
-
|
|
335
|
-
The core calls concrete renderers only through the
|
|
336
|
-
`KChartSeries.render(context)` contract.
|
|
337
|
-
|
|
338
|
-
## Quick Start
|
|
339
|
-
|
|
340
|
-
처음 시작할 때는 preset API를 사용하면 축과 series boilerplate를 줄일 수 있습니다.
|
|
60
|
+
Create a line chart with the preset API. `createLineChart(...)` renders immediately and returns a controller for later updates or cleanup.
|
|
341
61
|
|
|
342
62
|
```ts
|
|
343
|
-
import {createLineChart
|
|
63
|
+
import { createLineChart } from '@keneth80/k-chart';
|
|
344
64
|
|
|
345
65
|
type SalesPoint = {
|
|
346
66
|
month: string;
|
|
347
67
|
revenue: number;
|
|
348
|
-
orders: number;
|
|
349
68
|
};
|
|
350
69
|
|
|
351
70
|
const data: SalesPoint[] = [
|
|
352
|
-
{month: 'Jan', revenue: 42
|
|
353
|
-
{month: 'Feb', revenue: 48
|
|
354
|
-
{month: 'Mar', revenue: 45
|
|
71
|
+
{ month: 'Jan', revenue: 42 },
|
|
72
|
+
{ month: 'Feb', revenue: 48 },
|
|
73
|
+
{ month: 'Mar', revenue: 45 }
|
|
355
74
|
];
|
|
356
75
|
|
|
357
|
-
createLineChart<SalesPoint>({
|
|
358
|
-
selector: '#line-chart',
|
|
359
|
-
data,
|
|
360
|
-
x: {field: 'month', type: 'point', title: 'Month'},
|
|
361
|
-
y: {field: 'revenue', type: 'number', title: 'Revenue'},
|
|
362
|
-
title: 'Revenue Trend',
|
|
363
|
-
animation: true
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
chartConfig<SalesPoint>(data)
|
|
367
|
-
.selector('#column-chart')
|
|
368
|
-
.title('Orders By Month')
|
|
369
|
-
.x('month', 'point', {title: 'Month'})
|
|
370
|
-
.y('orders', 'number', {title: 'Orders'})
|
|
371
|
-
.column({color: '#56d08f'})
|
|
372
|
-
.tooltip()
|
|
373
|
-
.animation()
|
|
374
|
-
.render();
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
Preset API는 내부적으로 `KChartConfiguration`을 생성합니다. 더 세밀한 제어가 필요하면 아래 advanced API처럼 `createKChart(...)`, `axes`, `series`를 직접 구성하면 됩니다.
|
|
378
|
-
|
|
379
|
-
## Advanced Quick Start
|
|
380
|
-
|
|
381
|
-
```ts
|
|
382
|
-
import {
|
|
383
|
-
createKChart,
|
|
384
|
-
createLineSeries,
|
|
385
|
-
KChartController
|
|
386
|
-
} from '@keneth80/k-chart';
|
|
387
|
-
|
|
388
|
-
interface TrafficPoint {
|
|
389
|
-
time: string;
|
|
390
|
-
value: number;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
const data: TrafficPoint[] = [
|
|
394
|
-
{ time: '00:00', value: 12 },
|
|
395
|
-
{ time: '01:00', value: 18 },
|
|
396
|
-
{ time: '02:00', value: 21 }
|
|
397
|
-
];
|
|
398
|
-
|
|
399
|
-
const chart: KChartController<TrafficPoint> = createKChart<TrafficPoint>({
|
|
76
|
+
const chart = createLineChart<SalesPoint>({
|
|
400
77
|
selector: '#chart',
|
|
401
78
|
data,
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
],
|
|
406
|
-
series: [
|
|
407
|
-
createLineSeries({
|
|
408
|
-
selector: 'traffic-line',
|
|
409
|
-
displayName: 'Traffic',
|
|
410
|
-
xField: 'time',
|
|
411
|
-
yField: 'value',
|
|
412
|
-
curve: true,
|
|
413
|
-
dot: true
|
|
414
|
-
})
|
|
415
|
-
]
|
|
416
|
-
});
|
|
417
|
-
|
|
418
|
-
chart.render();
|
|
419
|
-
```
|
|
420
|
-
|
|
421
|
-
## Custom Series
|
|
422
|
-
|
|
423
|
-
아래 예제는 차트 코어가 계산한 x/y scale을 받아 SVG 원을 그립니다. Class 상속이나 interface 구현 없이 renderer 함수만 넘깁니다.
|
|
424
|
-
|
|
425
|
-
```ts
|
|
426
|
-
import {
|
|
427
|
-
createKChart,
|
|
428
|
-
createCustomSeries
|
|
429
|
-
} from '@keneth80/k-chart';
|
|
430
|
-
|
|
431
|
-
interface CirclePoint {
|
|
432
|
-
x: number;
|
|
433
|
-
y: number;
|
|
434
|
-
radius: number;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
const circleSeries = createCustomSeries<CirclePoint>({
|
|
438
|
-
selector: 'custom-circle',
|
|
439
|
-
displayName: 'Custom Circle',
|
|
440
|
-
xField: 'x',
|
|
441
|
-
yField: 'y',
|
|
442
|
-
render({ group, data, xScale, yScale, color }) {
|
|
443
|
-
if (!xScale || !yScale) {
|
|
444
|
-
return;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
group.selectAll('.custom-circle')
|
|
448
|
-
.data(data)
|
|
449
|
-
.join('circle')
|
|
450
|
-
.attr('class', 'custom-circle')
|
|
451
|
-
.attr('cx', (point) => xScale.scale(point.x))
|
|
452
|
-
.attr('cy', (point) => yScale.scale(point.y))
|
|
453
|
-
.attr('r', (point) => point.radius)
|
|
454
|
-
.style('fill', color)
|
|
455
|
-
.style('fill-opacity', 0.6);
|
|
456
|
-
}
|
|
79
|
+
x: { field: 'month', type: 'point', title: 'Month' },
|
|
80
|
+
y: { field: 'revenue', type: 'number', title: 'Revenue' },
|
|
81
|
+
title: 'Monthly Revenue'
|
|
457
82
|
});
|
|
458
83
|
|
|
459
|
-
|
|
460
|
-
selector: '#chart',
|
|
461
|
-
data: [
|
|
462
|
-
{ x: 1, y: 12, radius: 8 },
|
|
463
|
-
{ x: 2, y: 18, radius: 12 },
|
|
464
|
-
{ x: 3, y: 9, radius: 6 }
|
|
465
|
-
],
|
|
466
|
-
axes: [
|
|
467
|
-
{ field: 'x', type: 'number', placement: 'bottom', min: 0, max: 4 },
|
|
468
|
-
{ field: 'y', type: 'number', placement: 'left', min: 0, max: 24 }
|
|
469
|
-
],
|
|
470
|
-
series: [
|
|
471
|
-
circleSeries
|
|
472
|
-
]
|
|
473
|
-
}).render();
|
|
84
|
+
// Later: chart.updateData(nextData); chart.destroy();
|
|
474
85
|
```
|
|
475
86
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
## Canvas Or WebGL Renderer
|
|
87
|
+
For direct control over axes, series, layers, and options, continue to the [Advanced Quick Start](#advanced-quick-start) or read the [Functional API Guide](docs/functional-api.md).
|
|
479
88
|
|
|
480
|
-
|
|
89
|
+
## Try In StackBlitz
|
|
481
90
|
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
} from '@keneth80/k-chart';
|
|
489
|
-
|
|
490
|
-
const canvasLine = createCanvasLineSeries<Point>({
|
|
491
|
-
selector: 'canvas-line',
|
|
492
|
-
xField: 'x',
|
|
493
|
-
yField: 'y',
|
|
494
|
-
color: '#56d08f',
|
|
495
|
-
lineWidth: 3
|
|
496
|
-
});
|
|
497
|
-
|
|
498
|
-
const canvasPoints = createCanvasPointSeries<Point>({
|
|
499
|
-
selector: 'canvas-points',
|
|
500
|
-
xField: 'x',
|
|
501
|
-
yField: 'y',
|
|
502
|
-
radius: 4,
|
|
503
|
-
color: '#5db8ff'
|
|
504
|
-
});
|
|
91
|
+
| Start with | Best for |
|
|
92
|
+
| --- | --- |
|
|
93
|
+
| [Simple Line Preset](https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-simple-api-basic?title=KChart%20Simple%20API&file=src/main.ts) | Small, editable first example |
|
|
94
|
+
| [WebGL Line](https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-webgl-line-basic?title=KChart%20WebGL%20Line&file=src/main.ts) | Dense line rendering |
|
|
95
|
+
| [Custom Topology](https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-topology-basic?title=KChart%20Topology&file=src/main.ts) | Domain-specific Custom Series |
|
|
96
|
+
| [World Activity Map](https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-world-activity-map?title=KChart%20World%20Activity%20Map&file=src/main.ts) | SVG map visualization |
|
|
505
97
|
|
|
506
|
-
|
|
507
|
-
selector: 'webgl-points',
|
|
508
|
-
xField: 'x',
|
|
509
|
-
yField: 'y',
|
|
510
|
-
pointSize: 8,
|
|
511
|
-
color: '#f3b45b'
|
|
512
|
-
});
|
|
98
|
+
[View all example projects](examples/) · [Explore the live playground](https://k-chart-playground.vercel.app/)
|
|
513
99
|
|
|
514
|
-
|
|
515
|
-
selector: 'webgl-large-line',
|
|
516
|
-
displayName: '120k WebGL Line',
|
|
517
|
-
xField: 'x',
|
|
518
|
-
yField: 'y',
|
|
519
|
-
color: '#5db8ff',
|
|
520
|
-
lineWidth: 1,
|
|
521
|
-
downsample: {
|
|
522
|
-
enabled: true,
|
|
523
|
-
threshold: ({ plotSize }) => Math.floor(plotSize.width)
|
|
524
|
-
}
|
|
525
|
-
});
|
|
526
|
-
```
|
|
100
|
+
## Hybrid Rendering In 60 Seconds
|
|
527
101
|
|
|
528
|
-
|
|
102
|
+
<p align="center">
|
|
103
|
+
<a href="https://raw.githubusercontent.com/keneth80/k-chart/main/docs/promotion/kchart-hybrid-rendering-60s-ko.mp4">
|
|
104
|
+
<img src="docs/promotion/kchart-hybrid-rendering-preview.gif" alt="Watch the KChart hybrid rendering video" width="100%" />
|
|
105
|
+
</a>
|
|
106
|
+
</p>
|
|
529
107
|
|
|
530
|
-
|
|
108
|
+
<p align="center">
|
|
109
|
+
<a href="https://raw.githubusercontent.com/keneth80/k-chart/main/docs/promotion/kchart-hybrid-rendering-60s-ko.mp4"><strong>Watch the 60-second video</strong></a>
|
|
110
|
+
·
|
|
111
|
+
<a href="docs/promotion/hybrid-rendering-ko.md"><strong>Read the Korean technical article</strong></a>
|
|
112
|
+
</p>
|
|
531
113
|
|
|
532
|
-
|
|
533
|
-
import {
|
|
534
|
-
createCanvasCandlestickSeries,
|
|
535
|
-
createKChart
|
|
536
|
-
} from '@keneth80/k-chart';
|
|
114
|
+
## Architecture
|
|
537
115
|
|
|
538
|
-
|
|
539
|
-
date: string;
|
|
540
|
-
open: number;
|
|
541
|
-
high: number;
|
|
542
|
-
low: number;
|
|
543
|
-
close: number;
|
|
544
|
-
previousClose: number;
|
|
545
|
-
}
|
|
116
|
+
KChart separates chart coordination from visual rendering. The core resolves axes, scales, layout, interaction, and shared drawing layers; each series is a function that renders into SVG, Canvas, or WebGL with that shared context.
|
|
546
117
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
createKChart<StockPoint>({
|
|
554
|
-
selector: '#chart',
|
|
555
|
-
data,
|
|
556
|
-
axes: [
|
|
557
|
-
{ field: 'date', type: 'time', placement: 'bottom', tickCount: 5, domain: ['2026-05-31', '2026-06-04'] },
|
|
558
|
-
{
|
|
559
|
-
field: 'close',
|
|
560
|
-
type: 'number',
|
|
561
|
-
placement: 'left',
|
|
562
|
-
title: 'Price',
|
|
563
|
-
domainFields: ['low', 'high']
|
|
564
|
-
}
|
|
565
|
-
],
|
|
566
|
-
tooltip: { visible: true },
|
|
567
|
-
series: [
|
|
568
|
-
createCanvasCandlestickSeries({
|
|
569
|
-
selector: 'price',
|
|
570
|
-
displayName: 'Price',
|
|
571
|
-
xField: 'date',
|
|
572
|
-
openField: 'open',
|
|
573
|
-
highField: 'high',
|
|
574
|
-
lowField: 'low',
|
|
575
|
-
closeField: 'close',
|
|
576
|
-
colorMode: 'previous-close',
|
|
577
|
-
previousCloseField: 'previousClose',
|
|
578
|
-
upColor: '#22c55e',
|
|
579
|
-
downColor: '#ef4444'
|
|
580
|
-
})
|
|
581
|
-
]
|
|
582
|
-
}).render();
|
|
118
|
+
```text
|
|
119
|
+
createKChart(configuration)
|
|
120
|
+
-> core: layout, axes, scales, interaction, lifecycle
|
|
121
|
+
-> series: SVG | Canvas 2D | WebGL | custom renderer
|
|
122
|
+
-> options: guide lines, spec areas, cursor, range navigator, notes
|
|
123
|
+
-> controller: render, updateData, resize, destroy
|
|
583
124
|
```
|
|
584
125
|
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
## Globe Map
|
|
126
|
+
The public runtime is class-free. Presets such as `createLineChart(...)` and the fluent `chartConfig(...)` builder produce the same underlying configuration as direct composition.
|
|
588
127
|
|
|
589
|
-
|
|
128
|
+
KChart also includes business-oriented series for relationship, hierarchy, composition, and flow analysis:
|
|
590
129
|
|
|
591
|
-
|
|
130
|
+
- `createGraphSeries(...)` for source-target networks.
|
|
131
|
+
- `createTreeSeries(...)` for parent-child structures.
|
|
132
|
+
- `createTreemapSeries(...)` for part-to-whole comparison.
|
|
133
|
+
- `createSankeySeries(...)` for weighted process flows.
|
|
592
134
|
|
|
593
|
-
|
|
594
|
-
`@keneth80/k-chart-cesium` package. It accepts ordinary latitude/longitude
|
|
595
|
-
records, custom field mappings, or GeoJSON `LineString` routes. Timestamped
|
|
596
|
-
records are converted to Cesium `SampledPositionProperty` samples and can be
|
|
597
|
-
played through the Cesium clock with a moving marker, route trail, and optional
|
|
598
|
-
camera tracking. The adapter is provider-neutral by default: applications pass their own
|
|
599
|
-
`imageryProvider`, `terrainProvider`, optional `ionAccessToken`, and attribution.
|
|
600
|
-
Use `initialView` to set the first camera longitude, latitude, and height when
|
|
601
|
-
the default Cesium home view is too close for a dashboard panel. When timeline
|
|
602
|
-
or animation controls are visible, start farther out and set route
|
|
603
|
-
`flyToOnAdd: false` so the first render stays centered; call `handle.flyTo()` or
|
|
604
|
-
`controller.flyToRoute(id)` later when the user wants to focus the route.
|
|
605
|
-
Cesium atmosphere and lighting correction is enabled by default through
|
|
606
|
-
`realisticAtmosphere`, which adjusts only rendering settings and does not bundle
|
|
607
|
-
map, terrain, satellite, or 3D Tiles data. In 2D and Columbus View flat-map
|
|
608
|
-
modes, KChart disables Cesium lighting and atmosphere by default so the
|
|
609
|
-
day/night globe shadow does not cover the map; set
|
|
610
|
-
`realisticAtmosphere.disableLightingInFlatModes: false` only if that lighting is
|
|
611
|
-
intentional.
|
|
612
|
-
CesiumJS is Apache-2.0 licensed, while Cesium ion and third-party map, terrain,
|
|
613
|
-
satellite, place-search, or 3D Tiles services have separate terms. Do not
|
|
614
|
-
hard-code private provider keys in reusable library code, and keep Cesium/provider
|
|
615
|
-
credits and copyright notices visible.
|
|
135
|
+
See the [Functional API Guide](docs/functional-api.md) for package boundaries, concrete imports, and the complete extension model.
|
|
616
136
|
|
|
617
|
-
|
|
618
|
-
who import only core, SVG, Canvas, or WebGL chart modules do not include the
|
|
619
|
-
Cesium runtime in their application bundle. Load both `cesium` and
|
|
620
|
-
`@keneth80/k-chart-cesium` with `import()` when the globe route or panel opens
|
|
621
|
-
to keep Cesium in separate on-demand chunks. A static Cesium import can place
|
|
622
|
-
that runtime in the initial application bundle even when the globe is not yet
|
|
623
|
-
visible.
|
|
137
|
+
## Advanced Quick Start
|
|
624
138
|
|
|
625
|
-
|
|
626
|
-
camera tips are documented in
|
|
627
|
-
[`packages/k-chart-cesium/README.md`](packages/k-chart-cesium/README.md).
|
|
139
|
+
Use the core API when a chart needs multiple series, explicit axes, or custom behavior.
|
|
628
140
|
|
|
629
141
|
```ts
|
|
630
142
|
import {
|
|
631
143
|
createKChart,
|
|
632
|
-
|
|
144
|
+
createGuideLineOption,
|
|
145
|
+
createLineSeries
|
|
633
146
|
} from '@keneth80/k-chart';
|
|
634
147
|
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
url: string;
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
const cities: CityPoint[] = [
|
|
643
|
-
{ name: 'Seoul', lat: 37.5665, lon: 126.9780, url: 'https://en.wikipedia.org/wiki/Seoul' },
|
|
644
|
-
{ name: 'New York', lat: 40.7128, lon: -74.0060, url: 'https://en.wikipedia.org/wiki/New_York_City' }
|
|
645
|
-
];
|
|
646
|
-
|
|
647
|
-
createKChart<CityPoint>({
|
|
648
|
-
selector: '#chart',
|
|
649
|
-
data: cities,
|
|
650
|
-
grid: { visible: false },
|
|
651
|
-
legend: { visible: false },
|
|
652
|
-
tooltip: { visible: false },
|
|
653
|
-
axes: [],
|
|
654
|
-
series: [
|
|
655
|
-
createSvgGlobeSeries({
|
|
656
|
-
selector: 'cities',
|
|
657
|
-
latField: 'lat',
|
|
658
|
-
lonField: 'lon',
|
|
659
|
-
labelField: 'name',
|
|
660
|
-
initialRotate: [-120, -18, 0],
|
|
661
|
-
zoom: { enabled: true, min: 0.65, max: 3, controls: { visible: true, x: 6, y: 6 } },
|
|
662
|
-
landFill: '#22c55e',
|
|
663
|
-
landStroke: 'rgba(236, 253, 245, 0.72)',
|
|
664
|
-
landOpacity: 0.58,
|
|
665
|
-
countryBordersStroke: 'rgba(236, 253, 245, 0.28)',
|
|
666
|
-
drilldown: {
|
|
667
|
-
enabled: true,
|
|
668
|
-
mode: 'map',
|
|
669
|
-
autoMapOnZoom: true,
|
|
670
|
-
mapZoomThreshold: 2.4,
|
|
671
|
-
globeZoomThreshold: 1.8,
|
|
672
|
-
focusZoom: 2.7,
|
|
673
|
-
zoomScale: 7,
|
|
674
|
-
duration: 1200,
|
|
675
|
-
transition: {
|
|
676
|
-
type: 'cloud',
|
|
677
|
-
duration: 5000,
|
|
678
|
-
coverDuration: 3200,
|
|
679
|
-
revealDuration: 1800,
|
|
680
|
-
respectReducedMotion: false,
|
|
681
|
-
density: 0.86,
|
|
682
|
-
blur: 20
|
|
683
|
-
},
|
|
684
|
-
resetControl: true
|
|
685
|
-
},
|
|
686
|
-
onMarkerClick: ({ data }) => {
|
|
687
|
-
window.open(data.url, '_blank', 'noopener,noreferrer');
|
|
688
|
-
}
|
|
689
|
-
})
|
|
690
|
-
]
|
|
691
|
-
}).render();
|
|
692
|
-
```
|
|
693
|
-
|
|
694
|
-
Country-level styling is available when the land layer uses country features:
|
|
695
|
-
|
|
696
|
-
```ts
|
|
697
|
-
createSvgGlobeSeries({
|
|
698
|
-
selector: 'country-colors',
|
|
699
|
-
latField: 'lat',
|
|
700
|
-
lonField: 'lon',
|
|
701
|
-
landMode: 'countries',
|
|
702
|
-
landFill: (feature, index) => {
|
|
703
|
-
const name = feature.properties?.name;
|
|
704
|
-
if (name === 'South Korea') return '#60a5fa';
|
|
705
|
-
return ['#22c55e', '#14b8a6', '#f59e0b'][index % 3];
|
|
706
|
-
}
|
|
707
|
-
});
|
|
708
|
-
```
|
|
709
|
-
|
|
710
|
-
대용량 line 예제에서는 축 tick 수를 줄여 라벨 겹침을 피할 수 있습니다.
|
|
711
|
-
|
|
712
|
-
```ts
|
|
713
|
-
const largeData = Array.from({ length: 120000 }, (_, index) => ({
|
|
714
|
-
x: index,
|
|
715
|
-
y: 52 + Math.sin(index / 120) * 22 + Math.cos(index / 43) * 8
|
|
716
|
-
}));
|
|
717
|
-
|
|
718
|
-
createKChart({
|
|
719
|
-
selector: '#chart',
|
|
720
|
-
data: largeData,
|
|
721
|
-
axes: [
|
|
722
|
-
{
|
|
723
|
-
field: 'x',
|
|
724
|
-
type: 'number',
|
|
725
|
-
placement: 'bottom',
|
|
726
|
-
min: 0,
|
|
727
|
-
max: 119999,
|
|
728
|
-
tickCount: 6,
|
|
729
|
-
tickFormat: (value: number) => Math.round(value / 1000) + 'k'
|
|
730
|
-
},
|
|
731
|
-
{ field: 'y', type: 'number', placement: 'left', min: 0, max: 100, tickCount: 5 }
|
|
732
|
-
],
|
|
733
|
-
series: [webglLine]
|
|
734
|
-
}).render();
|
|
735
|
-
```
|
|
736
|
-
|
|
737
|
-
## Zoom
|
|
738
|
-
|
|
739
|
-
`zoom` 옵션을 켜면 number/time 축의 domain을 런타임에 갱신하면서 SVG, Canvas, WebGL series를 다시 렌더링합니다. 기본적으로 wheel/trackpad 확대, 드래그 pan, 더블클릭 reset을 지원합니다.
|
|
148
|
+
type MetricPoint = {
|
|
149
|
+
time: Date;
|
|
150
|
+
value: number;
|
|
151
|
+
};
|
|
740
152
|
|
|
741
|
-
|
|
742
|
-
createKChart({
|
|
153
|
+
const chart = createKChart<MetricPoint>({
|
|
743
154
|
selector: '#chart',
|
|
744
|
-
data:
|
|
745
|
-
|
|
746
|
-
{
|
|
747
|
-
{ field: 'y', type: 'number', placement: 'left', min: 0, max: 100 }
|
|
155
|
+
data: [
|
|
156
|
+
{ time: new Date('2026-01-01T00:00:00Z'), value: 42 },
|
|
157
|
+
{ time: new Date('2026-01-01T01:00:00Z'), value: 48 }
|
|
748
158
|
],
|
|
749
|
-
series: [webglLine],
|
|
750
|
-
zoom: {
|
|
751
|
-
enabled: true,
|
|
752
|
-
mode: 'both',
|
|
753
|
-
direction: 'x',
|
|
754
|
-
scaleExtent: [1, 80],
|
|
755
|
-
wheelZoom: { enabled: true, devices: 'pc', sensitivity: 0.85 },
|
|
756
|
-
gestureZoom: { enabled: true, devices: 'mobile', minTouches: 1 },
|
|
757
|
-
resetOnDoubleClick: true,
|
|
758
|
-
onZoom: ({ xDomain }) => {
|
|
759
|
-
console.log('visible x domain', xDomain);
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
}).render();
|
|
763
|
-
```
|
|
764
|
-
|
|
765
|
-
- `direction`: `'x'`, `'y'`, `'xy'` 중 하나입니다. 대용량 line 차트는 보통 `'x'`가 가장 자연스럽습니다.
|
|
766
|
-
- `mode`: `'wheel'`은 wheel/trackpad zoom과 drag pan, `'select'`는 드래그 영역 선택 zoom, `'both'`는 wheel/trackpad zoom과 드래그 영역 선택 zoom을 함께 사용합니다.
|
|
767
|
-
- `scaleExtent`: 최소/최대 확대 배율입니다.
|
|
768
|
-
- `wheelZoom`: PC wheel/trackpad 입력을 제어합니다. `devices`는 기본값이 `'pc'`이며, 필요하면 `'all'`로 바꿀 수 있습니다. `sensitivity`로 확대 민감도를 조절합니다.
|
|
769
|
-
- `gestureZoom`: 모바일 touch gesture 입력을 제어합니다. `devices`는 기본값이 `'mobile'`이며, `minTouches: 1`이면 한 손가락 pan과 두 손가락 pinch를 함께 허용합니다.
|
|
770
|
-
- `resetOnDoubleClick`: `false`로 지정하면 더블클릭 reset을 끌 수 있습니다.
|
|
771
|
-
|
|
772
|
-
## Line Downsampling
|
|
773
|
-
|
|
774
|
-
Line 계열 series는 `downsample` 옵션으로 LTTB 또는 픽셀 열별 min/max 축약을 사용할 수 있습니다. 원본 `data`와 축 domain은 그대로 유지하고, SVG/Canvas/WebGL renderer에 넘기는 series 데이터만 그리기 직전에 줄입니다.
|
|
775
|
-
|
|
776
|
-
```ts
|
|
777
|
-
createCanvasLineSeries<Point>({
|
|
778
|
-
selector: 'canvas-large-line',
|
|
779
|
-
xField: 'x',
|
|
780
|
-
yField: 'y',
|
|
781
|
-
downsample: true
|
|
782
|
-
});
|
|
783
|
-
```
|
|
784
|
-
|
|
785
|
-
`downsample: true`는 기본 threshold를 현재 plot width 픽셀 수로 잡습니다. 더 세밀하게 제어하려면 threshold나 accessor를 직접 지정할 수 있습니다.
|
|
786
|
-
|
|
787
|
-
```ts
|
|
788
|
-
createWebglLineSeries<Point>({
|
|
789
|
-
selector: 'webgl-large-line',
|
|
790
|
-
xField: 'time',
|
|
791
|
-
yField: 'signal',
|
|
792
|
-
downsample: {
|
|
793
|
-
enabled: true,
|
|
794
|
-
threshold: ({ plotSize }) => Math.max(400, Math.floor(plotSize.width * 1.5)),
|
|
795
|
-
xAccessor: (point) => point.time.getTime(),
|
|
796
|
-
yAccessor: (point) => point.signal
|
|
797
|
-
}
|
|
798
|
-
});
|
|
799
|
-
```
|
|
800
|
-
|
|
801
|
-
고밀도 numeric/time 시계열에서는 `min-max`가 각 픽셀 열의
|
|
802
|
-
first/min/max/last를 원본 순서대로 보존해 짧은 피크를 놓치지 않으면서 출력
|
|
803
|
-
point 수를 화면 폭에 비례하도록 제한합니다. 적용 가능 여부를 KChart에 맡기려면
|
|
804
|
-
`auto`를 사용합니다.
|
|
805
|
-
|
|
806
|
-
```ts
|
|
807
|
-
createWebglLineSeries<Point>({
|
|
808
|
-
selector: 'webgl-dense-signal',
|
|
809
|
-
xField: 'time',
|
|
810
|
-
yField: 'signal',
|
|
811
|
-
downsample: {
|
|
812
|
-
strategy: 'auto',
|
|
813
|
-
pointsPerPixel: 4
|
|
814
|
-
}
|
|
815
|
-
});
|
|
816
|
-
```
|
|
817
|
-
|
|
818
|
-
`auto`는 오름차순 number/time x축에서는 min-max를 선택하고, 범주형 축,
|
|
819
|
-
비정렬 입력, 결측값, 커스텀 accessor에서는 LTTB로 fallback합니다. 기존
|
|
820
|
-
`downsample: true`와 `strategy: 'lttb'`의 동작은 변경되지 않습니다.
|
|
821
|
-
명시적인 `strategy: 'min-max'`가 안전하지 않은 입력을 만나면 다른 알고리즘으로
|
|
822
|
-
바꾸지 않고 원본 renderer 입력을 유지합니다.
|
|
823
|
-
`pointsPerPixel`은 축약을 시작할 입력 밀도이며 결과는 픽셀 열당 최대 4개의
|
|
824
|
-
대표점과 선 연결을 위한 좌우 경계 이웃 최대 1개씩으로 제한됩니다.
|
|
825
|
-
|
|
826
|
-
필요하면 알고리즘만 직접 사용할 수도 있습니다.
|
|
827
|
-
|
|
828
|
-
```ts
|
|
829
|
-
import { downsampleLTTB } from '@keneth80/k-chart';
|
|
830
|
-
|
|
831
|
-
const sampled = downsampleLTTB(data, 1200, (point) => point.x, (point) => point.y);
|
|
832
|
-
```
|
|
833
|
-
|
|
834
|
-
## OffscreenCanvas Worker Rendering
|
|
835
|
-
|
|
836
|
-
Canvas/WebGL line series는 `asyncRender` 옵션으로 OffscreenCanvas + Web Worker 렌더링을 사용할 수 있습니다. SVG, axis, legend, tooltip DOM은 메인 스레드에 남고, Canvas/WebGL line draw 호출만 worker에서 실행됩니다. 미지원 환경이거나 `workerFactory`가 없으면 기존 메인 스레드 렌더러로 동작합니다.
|
|
837
|
-
|
|
838
|
-
Worker 파일을 하나 만듭니다.
|
|
839
|
-
|
|
840
|
-
```ts
|
|
841
|
-
// kchart-render.worker.ts
|
|
842
|
-
import { startKChartRenderWorker } from '@keneth80/k-chart';
|
|
843
|
-
|
|
844
|
-
startKChartRenderWorker();
|
|
845
|
-
```
|
|
846
|
-
|
|
847
|
-
series에서는 worker를 생성하는 factory를 넘깁니다.
|
|
848
|
-
|
|
849
|
-
```ts
|
|
850
|
-
createWebglLineSeries<Point>({
|
|
851
|
-
selector: 'webgl-large-line',
|
|
852
|
-
xField: 'x',
|
|
853
|
-
yField: 'signal',
|
|
854
|
-
downsample: {
|
|
855
|
-
enabled: true,
|
|
856
|
-
threshold: ({ plotSize }) => Math.floor(plotSize.width)
|
|
857
|
-
},
|
|
858
|
-
asyncRender: {
|
|
859
|
-
enabled: true,
|
|
860
|
-
workerFactory: () => new Worker(
|
|
861
|
-
new URL('./kchart-render.worker.ts', import.meta.url),
|
|
862
|
-
{ type: 'module' }
|
|
863
|
-
)
|
|
864
|
-
}
|
|
865
|
-
});
|
|
866
|
-
```
|
|
867
|
-
|
|
868
|
-
렌더 완료 시점을 측정하거나 후속 작업과 동기화해야 한다면 차트 컨트롤러의 완료 신호를 사용할 수 있습니다. Worker 렌더링을 쓰는 Canvas/WebGL line series는 worker가 draw를 끝낸 뒤 완료 메시지를 보내고, SVG/fallback 렌더링은 동기 렌더 후 완료됩니다.
|
|
869
|
-
|
|
870
|
-
```ts
|
|
871
|
-
const chart = createKChart<Point>({
|
|
872
|
-
selector: '#chart',
|
|
873
|
-
data,
|
|
874
|
-
axes,
|
|
875
|
-
series,
|
|
876
|
-
onRenderComplete: (event) => {
|
|
877
|
-
console.log(`render #${event.renderId} completed in ${event.duration.toFixed(1)}ms`);
|
|
878
|
-
}
|
|
879
|
-
});
|
|
880
|
-
|
|
881
|
-
chart.render();
|
|
882
|
-
await chart.whenRenderComplete();
|
|
883
|
-
```
|
|
884
|
-
|
|
885
|
-
같은 옵션은 `createCanvasLineSeries`에서도 사용할 수 있습니다.
|
|
886
|
-
|
|
887
|
-
JSON 데이터를 `fetch()`로 읽고 worker 생성 여부를 화면에서 확인하는 전체 예제는
|
|
888
|
-
[Worker JSON Line StackBlitz](https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-worker-json-line?title=KChart%20Worker%20JSON%20Line&file=src/main.ts)를 참고하세요.
|
|
889
|
-
이 예제는 API/data URL과 worker module URL이 서로 다른 역할이라는 점을 보여줍니다.
|
|
890
|
-
|
|
891
|
-
직접 제어가 필요하면 `render(context)` 안에서 Canvas/WebGL layer를 받을 수도 있습니다.
|
|
892
|
-
|
|
893
|
-
```ts
|
|
894
|
-
const customCanvasSeries = createCustomSeries<Point>({
|
|
895
|
-
selector: 'custom-canvas-points',
|
|
896
|
-
xField: 'x',
|
|
897
|
-
yField: 'y',
|
|
898
|
-
render({ getCanvas, data, xScale, yScale, color }) {
|
|
899
|
-
if (!xScale || !yScale) {
|
|
900
|
-
return;
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
const canvas = getCanvas('points');
|
|
904
|
-
const context = canvas.getContext('2d');
|
|
905
|
-
if (!context) {
|
|
906
|
-
return;
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
context.clearRect(0, 0, canvas.width, canvas.height);
|
|
910
|
-
context.fillStyle = color;
|
|
911
|
-
data.forEach((point) => {
|
|
912
|
-
context.beginPath();
|
|
913
|
-
context.arc(xScale.scale(point.x), yScale.scale(point.y), 3, 0, Math.PI * 2);
|
|
914
|
-
context.fill();
|
|
915
|
-
});
|
|
916
|
-
}
|
|
917
|
-
});
|
|
918
|
-
```
|
|
919
|
-
|
|
920
|
-
## Controller API
|
|
921
|
-
|
|
922
|
-
`createKChart(...)` returns `KChartController<T>`.
|
|
923
|
-
|
|
924
|
-
| Method | Description |
|
|
925
|
-
| --- | --- |
|
|
926
|
-
| `render()` | Render the chart. |
|
|
927
|
-
| `updateData(data)` | Replace data and render again. |
|
|
928
|
-
| `updateAxes(axes)` | Replace axes and render again. |
|
|
929
|
-
| `updateSeries(series)` | Replace series and render again. |
|
|
930
|
-
| `resize(size?)` | Recalculate size and render again. |
|
|
931
|
-
| `destroy()` | Remove SVG/Canvas resources. |
|
|
932
|
-
| `getState()` | Read current runtime state. |
|
|
933
|
-
|
|
934
|
-
## Chart Options
|
|
935
|
-
|
|
936
|
-
`createKChart(...)` supports layout and display options for common playground-style charts.
|
|
937
|
-
|
|
938
|
-
```ts
|
|
939
|
-
createKChart({
|
|
940
|
-
selector: '#chart',
|
|
941
|
-
data,
|
|
942
|
-
margin: { top: 28, right: 52, bottom: 44, left: 52 },
|
|
943
|
-
title: {
|
|
944
|
-
text: 'Hybrid Revenue And Volume',
|
|
945
|
-
align: 'left'
|
|
946
|
-
},
|
|
947
|
-
grid: {
|
|
948
|
-
visible: true,
|
|
949
|
-
x: false,
|
|
950
|
-
y: true,
|
|
951
|
-
dasharray: '2 6'
|
|
952
|
-
},
|
|
953
|
-
legend: {
|
|
954
|
-
visible: true,
|
|
955
|
-
placement: 'top',
|
|
956
|
-
selectable: true
|
|
957
|
-
},
|
|
958
|
-
tooltip: {
|
|
959
|
-
visible: true
|
|
960
|
-
},
|
|
961
|
-
animation: {
|
|
962
|
-
enabled: true,
|
|
963
|
-
duration: 820,
|
|
964
|
-
easing: 'easeOutCubic'
|
|
965
|
-
},
|
|
966
159
|
axes: [
|
|
967
|
-
{ field: '
|
|
968
|
-
{ field: 'value', type: 'number', placement: 'left'
|
|
969
|
-
{ field: 'volume', type: 'number', placement: 'right', title: 'Volume' }
|
|
160
|
+
{ field: 'time', type: 'time', placement: 'bottom' },
|
|
161
|
+
{ field: 'value', type: 'number', placement: 'left' }
|
|
970
162
|
],
|
|
971
163
|
series: [
|
|
972
|
-
createLineSeries({
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
Legend item은 기본적으로 선택 가능합니다. 여러 series를 넣으면 legend checkbox를 클릭해 SVG, Canvas, WebGL series를 개별적으로 숨기거나 다시 표시할 수 있습니다. `selectable: false`를 주면 표시 전용 legend로 동작합니다.
|
|
979
|
-
|
|
980
|
-
```ts
|
|
981
|
-
series: [
|
|
982
|
-
createLineSeries({ selector: 'value-line', displayName: 'Value', xField: 'x', yField: 'value' }),
|
|
983
|
-
createLineSeries({ selector: 'volume-line', displayName: 'Volume', xField: 'x', yField: 'volume' }),
|
|
984
|
-
createLineSeries({ selector: 'extra-line', displayName: 'Extra', xField: 'x', yField: 'extra' })
|
|
985
|
-
]
|
|
986
|
-
```
|
|
987
|
-
|
|
988
|
-
## Animation
|
|
989
|
-
|
|
990
|
-
`animation` 옵션은 최초 series 등장과 `updateData()` 전환을 제어합니다. `mode: 'enter'`에서는 supported series가 enter animation으로 렌더링되고, `mode: 'update'`에서는 `number`/`time` 축 domain을 이전 화면에서 새 화면까지 보간합니다. 따라서 실시간 시계열은 수신 간격마다 튀지 않고 연속해서 흐릅니다. Demo의 SVG column, stacked column, plot point, radial, pie, doughnut 같은 custom series도 `context.animation.progress`를 사용해 scale, opacity, arc sweep 효과를 적용합니다.
|
|
991
|
-
|
|
992
|
-
```ts
|
|
993
|
-
createKChart({
|
|
994
|
-
selector: '#chart',
|
|
995
|
-
data,
|
|
996
|
-
axes,
|
|
997
|
-
series: [
|
|
998
|
-
createLineSeries({ selector: 'value', xField: 'x', yField: 'value' }),
|
|
999
|
-
createCanvasLineSeries({ selector: 'volume', xField: 'x', yField: 'volume' })
|
|
164
|
+
createLineSeries({
|
|
165
|
+
selector: 'value',
|
|
166
|
+
xField: 'time',
|
|
167
|
+
yField: 'value',
|
|
168
|
+
color: '#0ea5e9'
|
|
169
|
+
})
|
|
1000
170
|
],
|
|
1001
|
-
animation: {
|
|
1002
|
-
enabled: true,
|
|
1003
|
-
duration: 820,
|
|
1004
|
-
easing: 'easeOutCubic',
|
|
1005
|
-
mode: 'enter',
|
|
1006
|
-
respectReducedMotion: true
|
|
1007
|
-
}
|
|
1008
|
-
}).render();
|
|
1009
|
-
```
|
|
1010
|
-
|
|
1011
|
-
실시간 차트는 `duration`을 데이터 수신 간격과 같게 두고 `easing: 'linear'`, `mode: 'update'`를 사용합니다. 새 데이터가 전환 도중 도착하면 현재 화면 위치에서 다음 domain으로 이어집니다. Worker-backed Canvas/WebGL line은 메시지 큐 증가를 막기 위해 update transition을 자동으로 생략하고 수신 주기당 한 번만 렌더합니다. 대용량 차트에서는 필요한 화면에서만 animation을 켜고 downsampling을 함께 사용하는 것을 권장합니다.
|
|
1012
|
-
|
|
1013
|
-
## Spec Areas, Fixed Guide Lines, And Cursor Guide
|
|
1014
|
-
|
|
1015
|
-
대용량 trace/WebGL 차트처럼 공정 단계나 관심 구간을 표시해야 할 때 `specAreas`를 사용할 수 있습니다.
|
|
1016
|
-
|
|
1017
|
-
옵션 기능은 series처럼 `options` 배열로 지정합니다. `createSpecAreaOption`, `createGuideLineOption`, `createCursorLineOption`을 조합하면 x/y 기준선, 영역, 마우스 추적선을 필요한 만큼 붙일 수 있습니다.
|
|
1018
|
-
|
|
1019
|
-
```ts
|
|
1020
|
-
import {
|
|
1021
|
-
createCursorLineOption,
|
|
1022
|
-
createGuideLineOption,
|
|
1023
|
-
createKChart,
|
|
1024
|
-
createSpecAreaOption,
|
|
1025
|
-
createWebglLineSeries
|
|
1026
|
-
} from '@keneth80/k-chart';
|
|
1027
|
-
|
|
1028
|
-
createKChart({
|
|
1029
|
-
selector: '#chart',
|
|
1030
|
-
data,
|
|
1031
171
|
options: [
|
|
1032
|
-
createSpecAreaOption([
|
|
1033
|
-
{ start: 18000, end: 36000, label: 'STEP 02', color: 'rgba(216, 118, 255, 0.16)' },
|
|
1034
|
-
{ start: 62000, end: 78000, label: 'STEP 05', color: 'rgba(93, 184, 255, 0.13)' }
|
|
1035
|
-
]),
|
|
1036
172
|
createGuideLineOption({
|
|
1037
|
-
|
|
1038
|
-
{ value: 1200, label: '1' },
|
|
1039
|
-
{ value: 6200, label: '2' },
|
|
1040
|
-
{ value: 24000, label: '3' },
|
|
1041
|
-
{ value: 64000, label: '4' }
|
|
1042
|
-
],
|
|
1043
|
-
y: [
|
|
1044
|
-
{ value: 80, label: 'upper', color: 'rgba(255, 107, 138, 0.55)' }
|
|
1045
|
-
]
|
|
1046
|
-
}),
|
|
1047
|
-
createCursorLineOption({
|
|
1048
|
-
xFormat: (value: number) => `${Math.round(value / 1000)}k`,
|
|
1049
|
-
valueFormat: (value: number) => Number(value).toFixed(1)
|
|
173
|
+
y: [{ value: 45, label: 'Target' }]
|
|
1050
174
|
})
|
|
1051
|
-
],
|
|
1052
|
-
series: [
|
|
1053
|
-
createWebglLineSeries({ selector: 'trace-1', displayName: 'Trace 1', xField: 'x', yField: 'signal0' }),
|
|
1054
|
-
createWebglLineSeries({ selector: 'trace-2', displayName: 'Trace 2', xField: 'x', yField: 'signal1' })
|
|
1055
175
|
]
|
|
1056
176
|
}).render();
|
|
1057
|
-
```
|
|
1058
|
-
|
|
1059
|
-
`createCursorLineOption`은 마우스 위치를 따라 가장 가까운 x 위치의 series 값을 읽어 보여주는 inspect overlay입니다. 기존 `specAreas`, `guideLines`, `cursorGuide`, `guideLine` 직접 필드는 호환을 위해 남아 있지만, 새 코드에서는 `options` 배열을 권장합니다.
|
|
1060
|
-
|
|
1061
|
-
## Range Navigator
|
|
1062
177
|
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
```ts
|
|
1066
|
-
createKChart({
|
|
1067
|
-
selector: '#chart',
|
|
1068
|
-
data: weeklyCommits,
|
|
1069
|
-
axes: [
|
|
1070
|
-
{field: 'week', type: 'time', placement: 'bottom'},
|
|
1071
|
-
{field: 'commits', type: 'number', placement: 'right', min: 0}
|
|
1072
|
-
],
|
|
1073
|
-
series: [createGroupedColumnSeries({
|
|
1074
|
-
selector: 'weekly-commits',
|
|
1075
|
-
displayName: 'Commits',
|
|
1076
|
-
xField: 'week',
|
|
1077
|
-
segments: [{field: 'commits', color: '#2f81f7'}]
|
|
1078
|
-
})],
|
|
1079
|
-
rangeNavigator: {
|
|
1080
|
-
xField: 'week',
|
|
1081
|
-
yField: 'commits',
|
|
1082
|
-
height: 58,
|
|
1083
|
-
gap: 14
|
|
1084
|
-
}
|
|
1085
|
-
}).render();
|
|
178
|
+
// chart.updateData(nextData);
|
|
179
|
+
// chart.destroy();
|
|
1086
180
|
```
|
|
1087
181
|
|
|
1088
|
-
|
|
182
|
+
## Choose A Renderer
|
|
1089
183
|
|
|
1090
|
-
|
|
184
|
+
| Renderer | Use it when | Typical series |
|
|
185
|
+
| --- | --- | --- |
|
|
186
|
+
| SVG | Data is moderate and DOM interaction or crisp labels matter most | Line, area, column, pie, graph, tree, map |
|
|
187
|
+
| Canvas 2D | Marks are dense and immediate-mode drawing is a good fit | Line, point, candlestick, custom overlays |
|
|
188
|
+
| WebGL | Lines or points are very large, frequently updated, or zoomed | Large line and point series |
|
|
189
|
+
| Custom Series | The domain needs its own visual grammar | Topology, operations views, specialized diagrams |
|
|
1091
190
|
|
|
1092
|
-
|
|
1093
|
-
tooltip: {
|
|
1094
|
-
visible: true,
|
|
1095
|
-
formatter: ({ data, series }) => `${series.displayName}: ${data.value}`
|
|
1096
|
-
}
|
|
1097
|
-
```
|
|
191
|
+
Dense line charts can use pixel-column min/max or LTTB downsampling. Canvas line rendering can also run through an OffscreenCanvas worker when supported. Configuration details, lifecycle rules, and fallback behavior are documented in the [Functional API Guide](docs/functional-api.md) and [Configuration Reference](docs/configuration-reference.md).
|
|
1098
192
|
|
|
1099
|
-
|
|
193
|
+
## Optional Integrations
|
|
1100
194
|
|
|
1101
|
-
|
|
195
|
+
Optional integrations stay outside the core dependency graph and are included only when the application imports them.
|
|
1102
196
|
|
|
1103
|
-
|
|
197
|
+
| Integration | Package or guide | Purpose |
|
|
198
|
+
| --- | --- | --- |
|
|
199
|
+
| React / Next.js | [`@keneth80/k-chart-react`](https://www.npmjs.com/package/@keneth80/k-chart-react) and [integration guide](docs/react-nextjs.md) | Component lifecycle, updates, and cleanup |
|
|
200
|
+
| Three.js | [`@keneth80/k-chart-three`](packages/k-chart-three/README.md) | 3D scenes using the Custom Series context |
|
|
201
|
+
| MapLibre | [`@keneth80/k-chart-maplibre`](packages/k-chart-maplibre/README.md) | Interactive vector maps, chart overlays, and the [subcell scalar-field example](https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-subcell-heatmap-basic?title=KChart%20Subcell%20Heat%20Field&file=src/main.ts) |
|
|
202
|
+
| Cesium | [`@keneth80/k-chart-cesium`](packages/k-chart-cesium/README.md) | 3D globe and geospatial visualization |
|
|
203
|
+
| Grafana | [KChart Panel](https://grafana.com/grafana/plugins/keneth80-kchart-panel/) | KChart-powered Line, Column, Area, Scatter, and Candlestick panels for Grafana dashboards |
|
|
1104
204
|
|
|
1105
|
-
|
|
1106
|
-
import {
|
|
1107
|
-
createKChart,
|
|
1108
|
-
createLineSeries,
|
|
1109
|
-
createTooltipNoteOption
|
|
1110
|
-
} from '@keneth80/k-chart';
|
|
205
|
+
## Features And Guides
|
|
1111
206
|
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
`<strong>${series.displayName}</strong><br/>${data.label}: ${data.value}`
|
|
1119
|
-
},
|
|
1120
|
-
options: [
|
|
1121
|
-
createTooltipNoteOption<Point>({
|
|
1122
|
-
maxNotes: 6,
|
|
1123
|
-
pinButtonLabel: 'Pin note',
|
|
1124
|
-
notePlaceholder: 'Write a memo...',
|
|
1125
|
-
onChange: (notes) => {
|
|
1126
|
-
// Save notes to application state or an API when needed.
|
|
1127
|
-
console.info(notes);
|
|
1128
|
-
}
|
|
1129
|
-
})
|
|
1130
|
-
],
|
|
1131
|
-
axes,
|
|
1132
|
-
series: [
|
|
1133
|
-
createLineSeries({
|
|
1134
|
-
selector: 'value',
|
|
1135
|
-
displayName: 'Value',
|
|
1136
|
-
xField: 'x',
|
|
1137
|
-
yField: 'value'
|
|
1138
|
-
})
|
|
1139
|
-
]
|
|
1140
|
-
}).render();
|
|
1141
|
-
```
|
|
207
|
+
- **Presets and builder**: start with `createLineChart(...)`, `createColumnChart(...)`, `createPieChart(...)`, or `chartConfig(...)` in the [Functional API Guide](docs/functional-api.md).
|
|
208
|
+
- **Built-in series**: line, area, column, bar, candlestick, pie, doughnut, scatter, bubble, histogram, box plot, gauge, waterfall, graph, tree, treemap, Sankey, globe, and more are indexed in the [examples directory](examples/).
|
|
209
|
+
- **Interaction and annotation**: zoom/pan, cursor guides, guide lines, spec areas, tooltip notes, and range navigation are covered by the [Configuration Reference](docs/configuration-reference.md).
|
|
210
|
+
- **Large data**: WebGL, min/max and LTTB downsampling, OffscreenCanvas workers, and controller updates are documented in the [Functional API Guide](docs/functional-api.md).
|
|
211
|
+
- **Custom rendering**: use `createCustomSeries(...)` for SVG, Canvas, WebGL, Three.js, or mixed-renderer views. Custom tooltip hit testing is documented with the API.
|
|
212
|
+
- **AI-assisted integration**: start with the [AI Agent Guide](docs/ai/agent-usage.md) or give an agent [`llms.txt`](llms.txt) for a compact API map.
|
|
1142
213
|
|
|
1143
|
-
|
|
214
|
+
## Development
|
|
1144
215
|
|
|
1145
|
-
```
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
xField: 'x',
|
|
1150
|
-
yField: 'value',
|
|
1151
|
-
render({ group, data, xScale, yScale }) {
|
|
1152
|
-
// draw stacked rects with the chart scales
|
|
1153
|
-
},
|
|
1154
|
-
tooltip({ data, scales, mouseX, mouseY }) {
|
|
1155
|
-
const xScale = scales.find((scale) => scale.field === 'x');
|
|
1156
|
-
const yScale = scales.find((scale) => scale.field === 'value');
|
|
1157
|
-
if (!xScale || !yScale) {
|
|
1158
|
-
return undefined;
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
const hit = data.find((point) => {
|
|
1162
|
-
const x = xScale.scale(point.x);
|
|
1163
|
-
return Math.abs(mouseX - x) < 12;
|
|
1164
|
-
});
|
|
1165
|
-
if (!hit) {
|
|
1166
|
-
return undefined;
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
return {
|
|
1170
|
-
data: hit,
|
|
1171
|
-
x: xScale.scale(hit.x),
|
|
1172
|
-
y: yScale.scale(hit.value),
|
|
1173
|
-
distance: 0,
|
|
1174
|
-
html: `<strong>${hit.label}</strong><br/>A: ${hit.a}<br/>B: ${hit.b}`
|
|
1175
|
-
};
|
|
1176
|
-
}
|
|
1177
|
-
});
|
|
216
|
+
```bash
|
|
217
|
+
npm ci
|
|
218
|
+
npm run ci:adapters
|
|
219
|
+
npm run dev
|
|
1178
220
|
```
|
|
1179
221
|
|
|
1180
|
-
|
|
222
|
+
The demo runs at `http://127.0.0.1:9003/`. Before opening a pull request, run the validation commands in [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
1181
223
|
|
|
1182
|
-
|
|
224
|
+
## Project Resources
|
|
1183
225
|
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
-
|
|
1195
|
-
-
|
|
1196
|
-
- `createCanvasLineSeries`
|
|
1197
|
-
- `createCanvasPointSeries`
|
|
1198
|
-
- `createWebglPointSeries`
|
|
1199
|
-
- `createCustomSeries`
|
|
1200
|
-
- `createSpecAreaOption`
|
|
1201
|
-
- `createGuideLineOption`
|
|
1202
|
-
- `createCursorLineOption`
|
|
1203
|
-
- `KChartController`
|
|
1204
|
-
|
|
1205
|
-
The next migration target is adding zoom/pan and richer tooltip interaction on top of this class-free runtime.
|
|
226
|
+
- [Functional API Guide](docs/functional-api.md)
|
|
227
|
+
- [Configuration Reference](docs/configuration-reference.md)
|
|
228
|
+
- [React And Next.js Guide](docs/react-nextjs.md)
|
|
229
|
+
- [Architecture And Refactor Plan](docs/refactor-plan.md)
|
|
230
|
+
- [Code Graph Handoff](docs/code-graph-handoff.md)
|
|
231
|
+
- [Release Guide](docs/release.md)
|
|
232
|
+
- [Examples](examples/)
|
|
233
|
+
- [Changelog](CHANGELOG.md)
|
|
234
|
+
- [Contributing](CONTRIBUTING.md)
|
|
235
|
+
- [Security Policy](SECURITY.md)
|
|
236
|
+
- [GitHub Releases](https://github.com/keneth80/k-chart/releases)
|
|
237
|
+
- [KChart Panel for Grafana](https://grafana.com/grafana/plugins/keneth80-kchart-panel/)
|
|
1206
238
|
|
|
1207
|
-
##
|
|
239
|
+
## License
|
|
1208
240
|
|
|
1209
|
-
|
|
1210
|
-
- [Refactor Plan](docs/refactor-plan.md)
|
|
241
|
+
MIT. See [LICENSE](LICENSE).
|