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