@keneth80/k-chart 1.24.1 → 1.26.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 +56 -0
- package/README.md +33 -2
- package/docs/ai/agent-usage.md +8 -3
- package/docs/configuration-reference.md +13 -6
- package/docs/functional-api.md +72 -1
- package/examples/stackblitz-doughnut-scroll-legend/index.html +46 -0
- package/examples/stackblitz-doughnut-scroll-legend/package.json +18 -0
- package/examples/stackblitz-doughnut-scroll-legend/src/main.ts +96 -0
- package/examples/stackblitz-doughnut-scroll-legend/src/style.css +267 -0
- package/examples/stackblitz-doughnut-scroll-legend/src/vite-env.d.ts +1 -0
- package/examples/stackblitz-world-activity-map/index.html +23 -0
- package/examples/stackblitz-world-activity-map/package.json +16 -0
- package/examples/stackblitz-world-activity-map/src/main.ts +77 -0
- package/examples/stackblitz-world-activity-map/src/style.css +78 -0
- package/examples/stackblitz-world-activity-map/src/vite-env.d.ts +1 -0
- package/examples/stackblitz-world-cluster-map/index.html +19 -0
- package/examples/stackblitz-world-cluster-map/package.json +19 -0
- package/examples/stackblitz-world-cluster-map/src/main.ts +78 -0
- package/examples/stackblitz-world-cluster-map/src/style.css +65 -0
- package/lib/core/contracts.d.ts +19 -0
- package/lib/core/contracts.d.ts.map +1 -1
- package/lib/internal/downsample.d.ts.map +1 -1
- package/lib/internal/downsample.js +248 -2
- package/lib/internal/downsample.js.map +1 -1
- package/lib/presets/index.d.ts +31 -0
- package/lib/presets/index.d.ts.map +1 -1
- package/lib/presets/index.js +185 -9
- package/lib/presets/index.js.map +1 -1
- package/lib/series/svg-region-map.d.ts +20 -1
- package/lib/series/svg-region-map.d.ts.map +1 -1
- package/lib/series/svg-region-map.js +181 -7
- package/lib/series/svg-region-map.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,61 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.26.0 - 2026-08-27
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Added pixel-column min/max downsampling for dense numeric and time-series
|
|
8
|
+
lines, preserving each visible column's first, minimum, maximum, and last
|
|
9
|
+
points in source order.
|
|
10
|
+
- Added `downsample.strategy` (`lttb`, `min-max`, or `auto`) and
|
|
11
|
+
`pointsPerPixel` configuration while preserving LTTB as the existing default.
|
|
12
|
+
- Added configurable MapLibre world clustering, single-world rendering,
|
|
13
|
+
bounds, cluster styling, cluster interaction callbacks, and toolbar controls
|
|
14
|
+
in `@keneth80/k-chart-maplibre` 0.2.0.
|
|
15
|
+
- Added a StackBlitz-ready clustered world map example and playground entry.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Dense Canvas and WebGL line demos now use the safe `auto` strategy so
|
|
20
|
+
continuous, ordered data can retain narrow spikes with output proportional
|
|
21
|
+
to plot width.
|
|
22
|
+
- Unsafe or unsupported automatic min/max inputs fall back to LTTB; explicit
|
|
23
|
+
`min-max` keeps the original renderer input instead of silently changing
|
|
24
|
+
algorithms.
|
|
25
|
+
|
|
26
|
+
### Tests
|
|
27
|
+
|
|
28
|
+
- Added regression coverage for numeric, Date, and ISO-time min/max sampling,
|
|
29
|
+
viewport boundaries, extrema order, invalid data, zoomed domains, automatic
|
|
30
|
+
fallback behavior, and output-size bounds.
|
|
31
|
+
- Added MapLibre configuration and runtime tests for clustering, world-copy
|
|
32
|
+
control, callbacks, styling expressions, bounds, and toolbar behavior.
|
|
33
|
+
|
|
34
|
+
## 1.25.0 - 2026-08-27
|
|
35
|
+
|
|
36
|
+
### Added
|
|
37
|
+
|
|
38
|
+
- Added configurable pie and doughnut `sliceLabel` formatters with access to
|
|
39
|
+
the original datum, value, total, percentage, index, and segment color.
|
|
40
|
+
- Added outside slice labels with leader lines, minimum-percentage and
|
|
41
|
+
maximum-count filtering, multi-line output, collision spacing, and plot-bound
|
|
42
|
+
clamping.
|
|
43
|
+
- Added continuous value coloring and a fixed color legend for SVG region maps,
|
|
44
|
+
including configurable domains, palettes, labels, placement, and styling.
|
|
45
|
+
- Added StackBlitz-ready world activity map and scrollable doughnut legend
|
|
46
|
+
examples.
|
|
47
|
+
|
|
48
|
+
### Changed
|
|
49
|
+
|
|
50
|
+
- Documented how to combine formatted outside doughnut labels with a separately
|
|
51
|
+
scrollable detail legend for dense category sets.
|
|
52
|
+
|
|
53
|
+
### Tests
|
|
54
|
+
|
|
55
|
+
- Added regression coverage for region-map color domains and legends, pie label
|
|
56
|
+
formatter contexts, filtering, collision layout, leader lines, and legacy
|
|
57
|
+
label visibility.
|
|
58
|
+
|
|
3
59
|
## 1.24.1 - 2026-08-26
|
|
4
60
|
|
|
5
61
|
### Changed
|
package/README.md
CHANGED
|
@@ -66,6 +66,10 @@
|
|
|
66
66
|
·
|
|
67
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
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
|
+
·
|
|
69
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>
|
|
70
74
|
·
|
|
71
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>
|
|
@@ -80,6 +84,8 @@
|
|
|
80
84
|
·
|
|
81
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>
|
|
82
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
|
+
·
|
|
83
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>
|
|
84
90
|
·
|
|
85
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>
|
|
@@ -758,9 +764,9 @@ createKChart({
|
|
|
758
764
|
- `gestureZoom`: 모바일 touch gesture 입력을 제어합니다. `devices`는 기본값이 `'mobile'`이며, `minTouches: 1`이면 한 손가락 pan과 두 손가락 pinch를 함께 허용합니다.
|
|
759
765
|
- `resetOnDoubleClick`: `false`로 지정하면 더블클릭 reset을 끌 수 있습니다.
|
|
760
766
|
|
|
761
|
-
##
|
|
767
|
+
## Line Downsampling
|
|
762
768
|
|
|
763
|
-
Line 계열 series는 `downsample` 옵션으로 LTTB
|
|
769
|
+
Line 계열 series는 `downsample` 옵션으로 LTTB 또는 픽셀 열별 min/max 축약을 사용할 수 있습니다. 원본 `data`와 축 domain은 그대로 유지하고, SVG/Canvas/WebGL renderer에 넘기는 series 데이터만 그리기 직전에 줄입니다.
|
|
764
770
|
|
|
765
771
|
```ts
|
|
766
772
|
createCanvasLineSeries<Point>({
|
|
@@ -787,6 +793,31 @@ createWebglLineSeries<Point>({
|
|
|
787
793
|
});
|
|
788
794
|
```
|
|
789
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
|
+
|
|
790
821
|
필요하면 알고리즘만 직접 사용할 수도 있습니다.
|
|
791
822
|
|
|
792
823
|
```ts
|
package/docs/ai/agent-usage.md
CHANGED
|
@@ -53,11 +53,16 @@ When implementing charts:
|
|
|
53
53
|
|
|
54
54
|
Codex reads `AGENTS.md`. Put project-wide instructions at the repository root and narrower instructions in subdirectories when a dashboard package needs different rules.
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
KChart does not commit a repository-specific `AGENTS.md`; maintainers may create
|
|
57
|
+
one locally when needed. In a consuming project, include the shared instruction
|
|
58
|
+
above and add exact build and test commands appropriate to that project.
|
|
57
59
|
|
|
58
60
|
## Claude Code
|
|
59
61
|
|
|
60
|
-
Claude Code reads `CLAUDE.md`.
|
|
62
|
+
Claude Code reads `CLAUDE.md`. KChart does not commit this tool-specific file;
|
|
63
|
+
maintainers or consuming projects may create one locally. Keep it short and
|
|
64
|
+
reference the same canonical documents instead of copying the catalog into the
|
|
65
|
+
file.
|
|
61
66
|
|
|
62
67
|
For local exceptions that must not be committed, use the tool's supported local instruction mechanism rather than placing tokens, provider keys, or private data in `CLAUDE.md`.
|
|
63
68
|
|
|
@@ -65,7 +70,7 @@ For local exceptions that must not be committed, use the tool's supported local
|
|
|
65
70
|
|
|
66
71
|
Use `.cursor/rules/*.mdc`; `.cursorrules` is legacy. A KChart rule should be focused, auto-attached to chart files where possible, and reference this guide plus `ai/catalog.json`.
|
|
67
72
|
|
|
68
|
-
|
|
73
|
+
Consumer projects can add their own Cursor rule when they use Cursor. KChart does not ship editor-specific project configuration in the library repository.
|
|
69
74
|
|
|
70
75
|
## Verification checklist
|
|
71
76
|
|
|
@@ -254,7 +254,7 @@ createKChart({
|
|
|
254
254
|
| `pointerEvents` | `'core' \| 'series'` | 기본값은 `core`입니다. 노드/링크가 직접 hover·click을 처리하는 custom series는 `series`를 지정하면 코어 tooltip이 상위 group에서 이벤트를 함께 수신합니다. |
|
|
255
255
|
| `xField` / `yField` | `keyof T & string` | 기본 tooltip, scale 선택, downsample에 쓰이는 field입니다. |
|
|
256
256
|
| `color` | `string` | series 색상입니다. 없으면 chart `colors` 팔레트에서 할당됩니다. |
|
|
257
|
-
| `downsample` | `boolean \| KChartDownsampleConfiguration<T>` | line 계열 renderer에서 LTTB downsampling을 적용합니다. |
|
|
257
|
+
| `downsample` | `boolean \| KChartDownsampleConfiguration<T>` | line 계열 renderer에서 LTTB 또는 픽셀 열별 min/max downsampling을 적용합니다. |
|
|
258
258
|
| `render(context)` | `function` | 실제 렌더링 함수입니다. custom series의 핵심 확장 지점입니다. |
|
|
259
259
|
| `tooltip(context)` | `function` | custom tooltip hit-test를 구현할 수 있습니다. |
|
|
260
260
|
| `clearTooltip(context)` | `function` | hover 종료 시 series highlight를 되돌릴 수 있습니다. |
|
|
@@ -273,7 +273,7 @@ createKChart({
|
|
|
273
273
|
| `strokeWidth` | `number` | `2` | SVG path stroke width입니다. |
|
|
274
274
|
| `curve` | `boolean` | `false` | `true`이면 `curveMonotoneX`를 사용합니다. |
|
|
275
275
|
| `dot` | `boolean \| { radius; fill; stroke }` | `false` | 각 point에 SVG circle을 표시합니다. |
|
|
276
|
-
| `downsample` | `boolean \| object` | disabled | LTTB
|
|
276
|
+
| `downsample` | `boolean \| object` | disabled | LTTB 또는 픽셀 열별 min/max 축약을 적용합니다. |
|
|
277
277
|
|
|
278
278
|
### SVG Area: `createAreaSeries`
|
|
279
279
|
|
|
@@ -285,7 +285,7 @@ createKChart({
|
|
|
285
285
|
| `fill` / `fillOpacity` | `string`, `number` | chart color, `0.26` | area fill 스타일입니다. |
|
|
286
286
|
| `stroke` / `strokeWidth` | `string`, `number` | chart color, `2` | area 상단 라인 스타일입니다. |
|
|
287
287
|
| `curve` | `boolean` | `false` | `true`이면 `curveMonotoneX`를 사용합니다. |
|
|
288
|
-
| `downsample` | `boolean \| object` | disabled | LTTB
|
|
288
|
+
| `downsample` | `boolean \| object` | disabled | LTTB 또는 픽셀 열별 min/max 축약을 적용합니다. |
|
|
289
289
|
|
|
290
290
|
### SVG Horizontal Bar: `createBarSeries`
|
|
291
291
|
|
|
@@ -560,7 +560,7 @@ createTreemapSeries<ProductShare>({
|
|
|
560
560
|
| `color` | `string` | chart color | stroke 색상입니다. |
|
|
561
561
|
| `lineWidth` | `number` | `2` | Canvas line width입니다. |
|
|
562
562
|
| `canvasName` | `string` | `selector` | canvas layer 이름입니다. 여러 series가 같은 canvas를 공유할 때 지정합니다. |
|
|
563
|
-
| `downsample` | `boolean \| object` | disabled | LTTB
|
|
563
|
+
| `downsample` | `boolean \| object` | disabled | LTTB 또는 픽셀 열별 min/max 축약을 적용합니다. |
|
|
564
564
|
| `asyncRender` | `KChartAsyncRenderConfiguration` | disabled | OffscreenCanvas + Worker line draw를 사용합니다. |
|
|
565
565
|
|
|
566
566
|
### Canvas Point: `createCanvasPointSeries`
|
|
@@ -605,7 +605,7 @@ createTreemapSeries<ProductShare>({
|
|
|
605
605
|
| `color` | `string` | chart color | line 색상입니다. |
|
|
606
606
|
| `lineWidth` | `number` | `1` | WebGL line width입니다. 브라우저/드라이버에 따라 1보다 큰 값이 제한될 수 있습니다. |
|
|
607
607
|
| `canvasName` | `string` | `selector` | WebGL canvas layer 이름입니다. |
|
|
608
|
-
| `downsample` | `boolean \| object` | disabled | LTTB
|
|
608
|
+
| `downsample` | `boolean \| object` | disabled | LTTB 또는 픽셀 열별 min/max 축약을 적용합니다. |
|
|
609
609
|
| `asyncRender` | `KChartAsyncRenderConfiguration` | disabled | OffscreenCanvas + Worker line draw를 사용합니다. |
|
|
610
610
|
|
|
611
611
|
### WebGL Point: `createWebglPointSeries`
|
|
@@ -670,10 +670,17 @@ WebGL point는 현재 interleaved buffer `[x, y, size]` 구조로 GPU에 전달
|
|
|
670
670
|
| Field | Type | Default | Description |
|
|
671
671
|
| --- | --- | --- | --- |
|
|
672
672
|
| `enabled` | `boolean` | `true` when object exists | false이면 downsampling을 끕니다. |
|
|
673
|
-
| `
|
|
673
|
+
| `strategy` | `'lttb' \| 'min-max' \| 'auto'` | `lttb` | `min-max`는 화면의 픽셀 열마다 first/min/max/last를 보존합니다. `auto`는 정렬된 number/time x축에만 min-max를 적용하고 나머지는 LTTB로 돌아갑니다. |
|
|
674
|
+
| `threshold` | `number \| (context) => number` | plot width | LTTB가 줄일 목표 point 수입니다. 보통 chart plot width를 사용하며 min-max 경로에서는 평가하지 않습니다. |
|
|
675
|
+
| `pointsPerPixel` | `number` | `4` | min-max 축약을 시작할 입력 밀도입니다. 보이는 데이터가 `plot width × pointsPerPixel`을 넘으면 축약합니다. 출력은 픽셀 열당 최대 4점과 선 연결용 좌우 경계 이웃 최대 1점씩입니다. |
|
|
674
676
|
| `xAccessor` | `(point) => number` | field 기반 | LTTB x 값 추출 함수입니다. |
|
|
675
677
|
| `yAccessor` | `(point) => number` | field 기반 | LTTB y 값 추출 함수입니다. |
|
|
676
678
|
|
|
679
|
+
`min-max`는 x 값이 오름차순인 고밀도 시계열 line에 적합합니다. 범주형 축,
|
|
680
|
+
비정렬 데이터, 결측값, 커스텀 accessor처럼 픽셀 열을 안전하게 계산할 수 없는 입력은
|
|
681
|
+
`strategy: 'auto'`에서 기존 LTTB 경로를 사용합니다. 명시적인 `min-max`에서는
|
|
682
|
+
알고리즘을 몰래 바꾸지 않고 원본 renderer 입력을 유지합니다.
|
|
683
|
+
|
|
677
684
|
## Worker Rendering
|
|
678
685
|
|
|
679
686
|
KChart의 Worker 렌더링은 opt-in입니다. 현재 파악된 실제 동작 범위는 다음과 같습니다.
|
package/docs/functional-api.md
CHANGED
|
@@ -698,7 +698,7 @@ const chart = createKChart<Point>({
|
|
|
698
698
|
|
|
699
699
|
### Downsampling
|
|
700
700
|
|
|
701
|
-
`createLineSeries`, `createCanvasLineSeries`, `createWebglLineSeries`는 `downsample` 옵션을 지원합니다. `true`를 넘기면 현재 plot width를 기준으로 LTTB가
|
|
701
|
+
`createLineSeries`, `createCanvasLineSeries`, `createWebglLineSeries`는 `downsample` 옵션을 지원합니다. `true`를 넘기면 기존과 동일하게 현재 plot width를 기준으로 LTTB가 적용됩니다. 객체를 넘기면 LTTB, 픽셀 열별 min/max, 안전한 자동 선택 전략을 사용할 수 있습니다.
|
|
702
702
|
|
|
703
703
|
```ts
|
|
704
704
|
createWebglLineSeries<Point>({
|
|
@@ -712,6 +712,30 @@ createWebglLineSeries<Point>({
|
|
|
712
712
|
});
|
|
713
713
|
```
|
|
714
714
|
|
|
715
|
+
정렬된 numeric/time 시계열은 `min-max`가 각 픽셀 열의 진입점, 최솟값,
|
|
716
|
+
최댓값, 이탈점을 원본 순서대로 보존합니다. 화면에 표현할 수 없는 중복 점은
|
|
717
|
+
줄이면서 짧은 피크와 급락은 유지하므로 대용량 모니터링 차트에 적합합니다.
|
|
718
|
+
|
|
719
|
+
```ts
|
|
720
|
+
createWebglLineSeries<Point>({
|
|
721
|
+
selector: 'dense-signal',
|
|
722
|
+
xField: 'time',
|
|
723
|
+
yField: 'signal',
|
|
724
|
+
downsample: {
|
|
725
|
+
strategy: 'auto',
|
|
726
|
+
pointsPerPixel: 4
|
|
727
|
+
}
|
|
728
|
+
});
|
|
729
|
+
```
|
|
730
|
+
|
|
731
|
+
`auto`는 오름차순 number/time x축처럼 픽셀 열을 안전하게 계산할 수 있을 때
|
|
732
|
+
min-max를 사용합니다. 범주형 축, 비정렬 입력, 결측값, 커스텀 accessor는 기존 LTTB로
|
|
733
|
+
fallback합니다. 알고리즘을 고정해야 하는 경우 `strategy: 'lttb'` 또는
|
|
734
|
+
`strategy: 'min-max'`를 명시합니다. 명시적인 min-max가 안전하지 않은 입력을
|
|
735
|
+
만나면 다른 알고리즘으로 바꾸지 않고 원본 renderer 입력을 유지합니다.
|
|
736
|
+
`pointsPerPixel`은 축약을 시작할 입력 밀도이며, 실제 결과는 픽셀 열마다 원본
|
|
737
|
+
순서의 대표점 최대 4개와 선 연결용 좌우 경계 이웃 최대 1개씩으로 제한됩니다.
|
|
738
|
+
|
|
715
739
|
알고리즘 자체도 export됩니다.
|
|
716
740
|
|
|
717
741
|
```ts
|
|
@@ -904,6 +928,24 @@ createWorldCountryMapSeries<Country>({
|
|
|
904
928
|
});
|
|
905
929
|
```
|
|
906
930
|
|
|
931
|
+
`colorLegend`를 사용하면 `valueField`의 숫자 값을 연속 색상으로 변환하고, 지도 확대와 무관하게 고정되는 범례를 함께 표시할 수 있습니다. `colorField` 또는 `fill`을 명시하면 기존 사용자 지정 색상이 우선합니다. `domain`을 생략하면 현재 데이터의 최솟값과 최댓값을 사용합니다.
|
|
932
|
+
|
|
933
|
+
```ts
|
|
934
|
+
createWorldCountryMapSeries<Country>({
|
|
935
|
+
selector: 'world-activity',
|
|
936
|
+
dataKey: 'name',
|
|
937
|
+
valueField: 'activity',
|
|
938
|
+
colorLegend: {
|
|
939
|
+
visible: true,
|
|
940
|
+
title: '국가별 활동 지수',
|
|
941
|
+
position: 'bottom-left',
|
|
942
|
+
domain: [0, 100],
|
|
943
|
+
colors: ['#274c77', '#2a9d8f', '#e9c46a', '#e76f51'],
|
|
944
|
+
labels: ['낮음', '보통', '높음', '매우 높음']
|
|
945
|
+
}
|
|
946
|
+
});
|
|
947
|
+
```
|
|
948
|
+
|
|
907
949
|
지도 위에 좌표 기반 강조 요소가 필요하면 `bubbles`와 `markers`를 함께 사용할 수 있습니다. 둘 다 일반적인 위도/경도 값을 사용하며 내부에서 `projection([lon, lat])`로 화면 좌표를 계산합니다. `bubbles`는 지도 위 원형 분포/규모 표현에 적합하고, `markers`는 사진 썸네일, 라벨, 핀 형태의 지점 표시를 제공합니다. `imageUrl`에는 일반 이미지 URL이나 `data:image/...` URI를 넣을 수 있습니다. 마커별 `onClick`을 지정하면 원본 marker, 화면 좌표, mouse event를 받아 팝업이나 상세 이동을 연결할 수 있습니다.
|
|
908
950
|
|
|
909
951
|
```ts
|
|
@@ -944,7 +986,9 @@ createWorldCountryMapSeries<Country>({
|
|
|
944
986
|
|
|
945
987
|
- [Korea Region Map StackBlitz](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)
|
|
946
988
|
- [World Country Map StackBlitz](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)
|
|
989
|
+
- [World Activity Map StackBlitz](https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-world-activity-map?title=KChart%20World%20Activity%20Map&file=src/main.ts)
|
|
947
990
|
- [World Photo Marker Map StackBlitz](https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-world-photo-marker-map?title=KChart%20World%20Photo%20Marker%20Map&file=src/main.ts)
|
|
991
|
+
- [World Cluster Map StackBlitz](https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-world-cluster-map?title=KChart%20World%20Cluster%20Map&file=src/main.ts)
|
|
948
992
|
|
|
949
993
|
## Display Options
|
|
950
994
|
|
|
@@ -970,6 +1014,33 @@ createKChart({
|
|
|
970
1014
|
|
|
971
1015
|
The default tooltip shows the active series name and nearest x/y values. Provide `tooltip.formatter` for custom HTML/text.
|
|
972
1016
|
|
|
1017
|
+
Pie and doughnut presets accept `sliceLabel` when labels need domain-specific text or an outside layout. The formatter receives the original datum together with the computed label, value, total, percentage, index, and segment color. Returning an array renders a multi-line SVG label.
|
|
1018
|
+
|
|
1019
|
+
```ts
|
|
1020
|
+
createDoughnutChart({
|
|
1021
|
+
selector: '#chart',
|
|
1022
|
+
data: services,
|
|
1023
|
+
label: 'label',
|
|
1024
|
+
value: 'value',
|
|
1025
|
+
innerRadiusRatio: 0.58,
|
|
1026
|
+
sliceLabel: {
|
|
1027
|
+
position: 'outside',
|
|
1028
|
+
formatter: ({data, percentage}) =>
|
|
1029
|
+
`${data.category} · ${percentage.toFixed(1)}%`,
|
|
1030
|
+
leaderLine: {visible: true, length: 16},
|
|
1031
|
+
minPercentage: 2.2,
|
|
1032
|
+
maxVisible: 12,
|
|
1033
|
+
collision: {minGap: 22, padding: 8}
|
|
1034
|
+
}
|
|
1035
|
+
});
|
|
1036
|
+
```
|
|
1037
|
+
|
|
1038
|
+
`minPercentage` and `maxVisible` keep dense outside labels readable; filtered slices remain in the chart and tooltip. Keep every category in the scrollable detail legend described below.
|
|
1039
|
+
|
|
1040
|
+
When one custom series has many internal categories, such as doughnut segments, keep its detailed legend separate from KChart's series legend. Set `legend.visible: false`, reserve chart margin for an HTML legend, and apply `overflow-y: auto` to a fixed-height list. The list can then scroll without moving or resizing the SVG plot; on narrow screens, place the same list below the chart.
|
|
1041
|
+
|
|
1042
|
+
Full example: [Scrollable Doughnut Legend StackBlitz](https://stackblitz.com/fork/github/keneth80/k-chart/tree/main/examples/stackblitz-doughnut-scroll-legend?title=KChart%20Scrollable%20Doughnut%20Legend&file=src/main.ts)
|
|
1043
|
+
|
|
973
1044
|
### Pinned Tooltip Notes
|
|
974
1045
|
|
|
975
1046
|
Tooltip notes are opt-in. `createTooltipNoteOption()` adds a pin action to the normal hover tooltip and renders each pinned snapshot as an editable annotation card over the chart. Drag a card header to move it without changing the original data coordinates. Pinned cards do not replace or block later hover tooltips.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="ko">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<meta
|
|
7
|
+
name="description"
|
|
8
|
+
content="KChart custom SVG doughnut chart with a scrollable HTML legend."
|
|
9
|
+
/>
|
|
10
|
+
<title>KChart Scrollable Doughnut Legend</title>
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<main class="page-shell">
|
|
14
|
+
<header class="page-header">
|
|
15
|
+
<p class="eyebrow">KChart · Custom SVG</p>
|
|
16
|
+
<h1>서비스 운영 현황</h1>
|
|
17
|
+
<p>많은 카테고리를 도넛 차트와 독립적인 스크롤 범례로 탐색합니다.</p>
|
|
18
|
+
</header>
|
|
19
|
+
|
|
20
|
+
<section class="dashboard-card" aria-label="서비스 워크로드 구성 차트">
|
|
21
|
+
<div class="chart-region">
|
|
22
|
+
<div id="chart"></div>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<aside class="legend-panel" aria-labelledby="legend-title">
|
|
26
|
+
<header class="legend-header">
|
|
27
|
+
<div>
|
|
28
|
+
<p class="legend-kicker">최근 24시간</p>
|
|
29
|
+
<h2 id="legend-title">서비스별 활성 세션</h2>
|
|
30
|
+
</div>
|
|
31
|
+
<span class="legend-count" id="legend-count"></span>
|
|
32
|
+
</header>
|
|
33
|
+
<div class="legend-scroll" tabindex="0" aria-label="서비스 범례 스크롤 영역">
|
|
34
|
+
<ul id="legend-list" class="legend-list"></ul>
|
|
35
|
+
</div>
|
|
36
|
+
<footer class="legend-footer">
|
|
37
|
+
<span>단위</span>
|
|
38
|
+
<strong>세션</strong>
|
|
39
|
+
</footer>
|
|
40
|
+
</aside>
|
|
41
|
+
</section>
|
|
42
|
+
</main>
|
|
43
|
+
|
|
44
|
+
<script type="module" src="/src/main.ts"></script>
|
|
45
|
+
</body>
|
|
46
|
+
</html>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "kchart-doughnut-scroll-legend",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite --host 0.0.0.0",
|
|
8
|
+
"build": "tsc && vite build",
|
|
9
|
+
"preview": "vite preview --host 0.0.0.0"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@keneth80/k-chart": "^1.26.0"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"typescript": "^6.0.3",
|
|
16
|
+
"vite": "^7.2.7"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {createDoughnutChart} from '@keneth80/k-chart/presets';
|
|
2
|
+
import './style.css';
|
|
3
|
+
|
|
4
|
+
interface ServicePoint {
|
|
5
|
+
id: string;
|
|
6
|
+
label: string;
|
|
7
|
+
value: number;
|
|
8
|
+
color: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const services: ServicePoint[] = [
|
|
12
|
+
{id: 'monitoring', label: '실시간 모니터링', value: 68420, color: '#22d3ee'},
|
|
13
|
+
{id: 'pipeline', label: '데이터 파이프라인', value: 57180, color: '#38bdf8'},
|
|
14
|
+
{id: 'gateway', label: 'API 게이트웨이', value: 49360, color: '#60a5fa'},
|
|
15
|
+
{id: 'analytics', label: '사용자 분석', value: 42640, color: '#818cf8'},
|
|
16
|
+
{id: 'automation', label: '알림 자동화', value: 37120, color: '#a78bfa'},
|
|
17
|
+
{id: 'search', label: '검색 인덱스', value: 32980, color: '#c084fc'},
|
|
18
|
+
{id: 'storage', label: '파일 스토리지', value: 28410, color: '#e879f9'},
|
|
19
|
+
{id: 'workspace', label: '협업 워크스페이스', value: 24680, color: '#f472b6'},
|
|
20
|
+
{id: 'payments', label: '결제 처리', value: 21340, color: '#fb7185'},
|
|
21
|
+
{id: 'reports', label: '보고서 빌더', value: 18720, color: '#fb923c'},
|
|
22
|
+
{id: 'access', label: '접근 제어', value: 16290, color: '#fbbf24'},
|
|
23
|
+
{id: 'archive', label: '백업 아카이브', value: 13980, color: '#a3e635'},
|
|
24
|
+
{id: 'inference', label: '머신러닝 추론', value: 11860, color: '#4ade80'},
|
|
25
|
+
{id: 'events', label: '이벤트 스트림', value: 9720, color: '#2dd4bf'},
|
|
26
|
+
{id: 'audit', label: '감사 로그', value: 7640, color: '#14b8a6'},
|
|
27
|
+
{id: 'utilities', label: '기타 운영 도구', value: 5260, color: '#94a3b8'}
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
const numberFormatter = new Intl.NumberFormat('ko-KR');
|
|
31
|
+
const total = services.reduce((sum, service) => sum + service.value, 0);
|
|
32
|
+
const legendList = document.querySelector<HTMLUListElement>('#legend-list');
|
|
33
|
+
const legendCount = document.querySelector<HTMLElement>('#legend-count');
|
|
34
|
+
const chartHost = document.querySelector<HTMLElement>('#chart');
|
|
35
|
+
|
|
36
|
+
if (!legendList || !legendCount || !chartHost) {
|
|
37
|
+
throw new Error('The chart example container is missing.');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
legendCount.textContent = `${services.length}개`;
|
|
41
|
+
legendList.replaceChildren(...services.map((service) => {
|
|
42
|
+
const share = service.value / total * 100;
|
|
43
|
+
const item = document.createElement('li');
|
|
44
|
+
item.className = 'legend-item';
|
|
45
|
+
item.innerHTML = `
|
|
46
|
+
<span class="legend-swatch" style="--series-color:${service.color}"></span>
|
|
47
|
+
<span class="legend-name">${service.label}</span>
|
|
48
|
+
<span class="legend-metric">
|
|
49
|
+
<strong>${numberFormatter.format(service.value)}</strong>
|
|
50
|
+
<small>${share.toFixed(1)}%</small>
|
|
51
|
+
</span>
|
|
52
|
+
`;
|
|
53
|
+
return item;
|
|
54
|
+
}));
|
|
55
|
+
|
|
56
|
+
const resolveChartHeight = (): number => window.innerWidth <= 720 ? 390 : 520;
|
|
57
|
+
const resolveChartWidth = (): number => Math.max(chartHost.clientWidth, 320);
|
|
58
|
+
|
|
59
|
+
// The preset owns the doughnut geometry, hit testing, tooltip, leader lines,
|
|
60
|
+
// and collision layout. The adjacent HTML legend only handles dense browsing.
|
|
61
|
+
const chart = createDoughnutChart<ServicePoint>({
|
|
62
|
+
selector: '#chart',
|
|
63
|
+
data: services,
|
|
64
|
+
width: resolveChartWidth(),
|
|
65
|
+
height: resolveChartHeight(),
|
|
66
|
+
margin: {top: 86, right: 18, bottom: 18, left: 18},
|
|
67
|
+
title: {text: '서비스 워크로드 구성', align: 'center', fontSize: 19},
|
|
68
|
+
grid: false,
|
|
69
|
+
legend: false,
|
|
70
|
+
tooltip: true,
|
|
71
|
+
label: 'label',
|
|
72
|
+
value: 'value',
|
|
73
|
+
displayName: '활성 세션',
|
|
74
|
+
innerRadiusRatio: 0.62,
|
|
75
|
+
palette: services.map((service) => service.color),
|
|
76
|
+
sliceLabel: {
|
|
77
|
+
position: 'outside',
|
|
78
|
+
formatter: ({data, percentage}) => `${data.label} · ${percentage.toFixed(1)}%`,
|
|
79
|
+
leaderLine: {visible: true, length: 18, width: 1.2},
|
|
80
|
+
minPercentage: 2.2,
|
|
81
|
+
maxVisible: 12,
|
|
82
|
+
collision: {minGap: 10, padding: 8}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
let resizeFrame = 0;
|
|
87
|
+
const resizeChart = () => {
|
|
88
|
+
cancelAnimationFrame(resizeFrame);
|
|
89
|
+
resizeFrame = requestAnimationFrame(() => {
|
|
90
|
+
chart.resize({width: resolveChartWidth(), height: resolveChartHeight()});
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const resizeObserver = new ResizeObserver(resizeChart);
|
|
95
|
+
resizeObserver.observe(chartHost);
|
|
96
|
+
window.addEventListener('resize', resizeChart);
|