@keneth80/k-chart 1.9.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +204 -1
  3. package/docs/assets/kchart-hero.svg +110 -0
  4. package/docs/assets/kchart-icon.svg +40 -0
  5. package/docs/configuration-reference.md +395 -0
  6. package/docs/functional-api.md +103 -3
  7. package/examples/stackblitz-candlestick-basic/index.html +23 -0
  8. package/examples/stackblitz-candlestick-basic/package-lock.json +1435 -0
  9. package/examples/stackblitz-candlestick-basic/package.json +18 -0
  10. package/examples/stackblitz-candlestick-basic/src/main.ts +107 -0
  11. package/examples/stackblitz-candlestick-basic/src/style.css +16 -0
  12. package/examples/stackblitz-canvas-line-basic/index.html +23 -0
  13. package/examples/stackblitz-canvas-line-basic/package-lock.json +1435 -0
  14. package/examples/stackblitz-canvas-line-basic/package.json +18 -0
  15. package/examples/stackblitz-canvas-line-basic/src/main.ts +73 -0
  16. package/examples/stackblitz-canvas-line-basic/src/style.css +46 -0
  17. package/examples/stackblitz-column-basic/index.html +23 -0
  18. package/examples/stackblitz-column-basic/package-lock.json +1435 -0
  19. package/examples/stackblitz-column-basic/package.json +18 -0
  20. package/examples/stackblitz-column-basic/src/main.ts +128 -0
  21. package/examples/stackblitz-column-basic/src/style.css +41 -0
  22. package/examples/stackblitz-doughnut-basic/index.html +21 -0
  23. package/examples/stackblitz-doughnut-basic/package-lock.json +1435 -0
  24. package/examples/stackblitz-doughnut-basic/package.json +18 -0
  25. package/examples/stackblitz-doughnut-basic/src/main.ts +177 -0
  26. package/examples/stackblitz-doughnut-basic/src/style.css +43 -0
  27. package/examples/stackblitz-line-basic/index.html +23 -0
  28. package/examples/stackblitz-line-basic/package-lock.json +1435 -0
  29. package/examples/stackblitz-line-basic/package.json +18 -0
  30. package/examples/stackblitz-line-basic/src/main.ts +112 -0
  31. package/examples/stackblitz-line-basic/src/style.css +108 -0
  32. package/examples/stackblitz-multi-series-basic/index.html +1 -0
  33. package/examples/stackblitz-multi-series-basic/package-lock.json +1435 -0
  34. package/examples/stackblitz-multi-series-basic/package.json +9 -0
  35. package/examples/stackblitz-multi-series-basic/src/main.ts +29 -0
  36. package/examples/stackblitz-multi-series-basic/src/style.css +1 -0
  37. package/examples/stackblitz-options-basic/index.html +1 -0
  38. package/examples/stackblitz-options-basic/package-lock.json +1435 -0
  39. package/examples/stackblitz-options-basic/package.json +9 -0
  40. package/examples/stackblitz-options-basic/src/main.ts +32 -0
  41. package/examples/stackblitz-options-basic/src/style.css +1 -0
  42. package/examples/stackblitz-pie-basic/index.html +21 -0
  43. package/examples/stackblitz-pie-basic/package-lock.json +1435 -0
  44. package/examples/stackblitz-pie-basic/package.json +18 -0
  45. package/examples/stackblitz-pie-basic/src/main.ts +156 -0
  46. package/examples/stackblitz-pie-basic/src/style.css +43 -0
  47. package/examples/stackblitz-plot-basic/index.html +1 -0
  48. package/examples/stackblitz-plot-basic/package-lock.json +1435 -0
  49. package/examples/stackblitz-plot-basic/package.json +9 -0
  50. package/examples/stackblitz-plot-basic/src/main.ts +32 -0
  51. package/examples/stackblitz-plot-basic/src/style.css +1 -0
  52. package/examples/stackblitz-radial-basic/index.html +21 -0
  53. package/examples/stackblitz-radial-basic/package-lock.json +1435 -0
  54. package/examples/stackblitz-radial-basic/package.json +18 -0
  55. package/examples/stackblitz-radial-basic/src/main.ts +223 -0
  56. package/examples/stackblitz-radial-basic/src/style.css +87 -0
  57. package/examples/stackblitz-simple-api-basic/index.html +30 -0
  58. package/examples/stackblitz-simple-api-basic/package-lock.json +1435 -0
  59. package/examples/stackblitz-simple-api-basic/package.json +18 -0
  60. package/examples/stackblitz-simple-api-basic/src/main.ts +69 -0
  61. package/examples/stackblitz-simple-api-basic/src/style.css +127 -0
  62. package/examples/stackblitz-stacked-column-basic/index.html +23 -0
  63. package/examples/stackblitz-stacked-column-basic/package-lock.json +1435 -0
  64. package/examples/stackblitz-stacked-column-basic/package.json +18 -0
  65. package/examples/stackblitz-stacked-column-basic/src/main.ts +136 -0
  66. package/examples/stackblitz-stacked-column-basic/src/style.css +16 -0
  67. package/examples/stackblitz-three-wafer-basic/index.html +1 -0
  68. package/examples/stackblitz-three-wafer-basic/package-lock.json +1453 -0
  69. package/examples/stackblitz-three-wafer-basic/package.json +9 -0
  70. package/examples/stackblitz-three-wafer-basic/src/main.ts +29 -0
  71. package/examples/stackblitz-three-wafer-basic/src/style.css +1 -0
  72. package/examples/stackblitz-topology-basic/index.html +1 -0
  73. package/examples/stackblitz-topology-basic/package-lock.json +1435 -0
  74. package/examples/stackblitz-topology-basic/package.json +9 -0
  75. package/examples/stackblitz-topology-basic/src/main.ts +89 -0
  76. package/examples/stackblitz-topology-basic/src/style.css +1 -0
  77. package/examples/stackblitz-webgl-line-basic/index.html +23 -0
  78. package/examples/stackblitz-webgl-line-basic/package-lock.json +1435 -0
  79. package/examples/stackblitz-webgl-line-basic/package.json +18 -0
  80. package/examples/stackblitz-webgl-line-basic/src/main.ts +86 -0
  81. package/examples/stackblitz-webgl-line-basic/src/style.css +46 -0
  82. package/examples/stackblitz-worker-json-line/index.html +41 -0
  83. package/examples/stackblitz-worker-json-line/package-lock.json +1435 -0
  84. package/examples/stackblitz-worker-json-line/package.json +19 -0
  85. package/examples/stackblitz-worker-json-line/public/data/large-line.json +4322 -0
  86. package/examples/stackblitz-worker-json-line/src/kchart-render.worker.ts +4 -0
  87. package/examples/stackblitz-worker-json-line/src/main.ts +185 -0
  88. package/examples/stackblitz-worker-json-line/src/style.css +101 -0
  89. package/lib/core/contracts.d.ts +22 -0
  90. package/lib/core/contracts.d.ts.map +1 -1
  91. package/lib/core/create-kchart.d.ts.map +1 -1
  92. package/lib/core/create-kchart.js +93 -4
  93. package/lib/core/create-kchart.js.map +1 -1
  94. package/lib/index.d.ts +1 -0
  95. package/lib/index.d.ts.map +1 -1
  96. package/lib/index.js +1 -0
  97. package/lib/index.js.map +1 -1
  98. package/lib/kchart.d.ts +1 -0
  99. package/lib/kchart.d.ts.map +1 -1
  100. package/lib/kchart.js +1 -0
  101. package/lib/kchart.js.map +1 -1
  102. package/lib/presets/index.d.ts +97 -0
  103. package/lib/presets/index.d.ts.map +1 -0
  104. package/lib/presets/index.js +481 -0
  105. package/lib/presets/index.js.map +1 -0
  106. package/lib/series/canvas-line.d.ts.map +1 -1
  107. package/lib/series/canvas-line.js +16 -11
  108. package/lib/series/canvas-line.js.map +1 -1
  109. package/lib/series/svg-line.d.ts.map +1 -1
  110. package/lib/series/svg-line.js +19 -3
  111. package/lib/series/svg-line.js.map +1 -1
  112. package/lib/series/webgl-line.d.ts.map +1 -1
  113. package/lib/series/webgl-line.js +10 -3
  114. package/lib/series/webgl-line.js.map +1 -1
  115. package/package.json +13 -2
@@ -0,0 +1,395 @@
1
+ # KChart Configuration Reference
2
+
3
+ 이 문서는 KChart를 적용할 때 자주 헷갈리는 configuration 항목을 한 곳에서 확인하기 위한 참조 문서입니다. 실제 public type은 `src/core/contracts.ts`를 기준으로 하며, 아래 표는 각 옵션의 역할과 기본 동작을 설명합니다.
4
+
5
+ ## Quick Mental Model
6
+
7
+ ```ts
8
+ createKChart({
9
+ selector,
10
+ data,
11
+ axes,
12
+ series,
13
+ options
14
+ });
15
+ ```
16
+
17
+ - `createKChart(...)`: container, data, axis, layout, layer, interaction을 준비합니다.
18
+ - `axes`: scale과 axis를 정의합니다. `number`와 `time` 축은 zoom 대상이 될 수 있고, `string`과 `point` 축은 순서형 축이므로 zoom 대상에서 제외됩니다.
19
+ - `series`: 실제 데이터를 그리는 renderer입니다. SVG, Canvas, WebGL, custom renderer를 섞어 사용할 수 있습니다.
20
+ - `options`: spec area, fixed guide line, cursor line, tooltip note 같은 부가 기능입니다.
21
+ - Canvas/WebGL line series는 `asyncRender`를 켜면 OffscreenCanvas + Web Worker로 line draw를 넘길 수 있습니다.
22
+
23
+ ## Core Chart Configuration
24
+
25
+ | Field | Type | Required | Default | Description |
26
+ | --- | --- | ---: | --- | --- |
27
+ | `selector` | `string \| HTMLElement` | yes | - | 차트를 붙일 DOM container입니다. 문자열이면 CSS selector로 찾습니다. |
28
+ | `data` | `T[]` | yes | - | 차트 전체 데이터입니다. 모든 series와 axis domain 계산이 이 배열을 기준으로 동작합니다. |
29
+ | `axes` | `KChartAxis<T>[]` | yes | - | x/y/top/right scale과 axis 정의입니다. |
30
+ | `series` | `KChartSeries<T>[]` | yes | - | 렌더링할 series 목록입니다. |
31
+ | `options` | `KChartOption<T>[]` | no | `[]` | spec area, guide line, cursor line, tooltip note 등 plugin형 옵션입니다. |
32
+ | `width` | `number` | no | container width or `320` | 전체 SVG/canvas width입니다. |
33
+ | `height` | `number` | no | container height or `240` | 전체 SVG/canvas height입니다. |
34
+ | `margin` | `Partial<KChartMargin>` | no | `{ top: 24, right: 24, bottom: 36, left: 44 }` | plot 영역 바깥 여백입니다. title, top legend, option label이 있으면 top margin은 자동 보정될 수 있습니다. |
35
+ | `colors` | `string[]` | no | D3 `schemeCategory10` | series별 기본 색상 팔레트입니다. series `color`가 없을 때 순서대로 사용됩니다. |
36
+ | `className` | `string` | no | - | root container에 추가할 class입니다. |
37
+ | `title` | `KChartTitleConfiguration` | no | - | 차트 제목 설정입니다. |
38
+ | `grid` | `KChartGridConfiguration` | no | `{ visible: true }` equivalent | plot grid 표시 설정입니다. |
39
+ | `legend` | `KChartLegendConfiguration` | no | visible top legend | series 표시/숨김 범례 설정입니다. |
40
+ | `tooltip` | `KChartTooltipConfiguration<T>` | no | basic tooltip | nearest point tooltip 설정입니다. |
41
+ | `zoom` | `KChartZoomConfiguration<T>` | no | disabled | number/time 축 zoom, pan, 영역 선택 zoom 설정입니다. |
42
+ | `animation` | `boolean \| KChartAnimationConfiguration` | no | disabled | series enter animation 설정입니다. 현재 SVG/Canvas/WebGL line 계열 renderer가 기본 지원합니다. |
43
+ | `specAreas` | `KChartSpecAreaConfiguration[]` | no | `[]` | 기존 호환 필드입니다. 새 코드는 `createSpecAreaOption(...)` 사용을 권장합니다. |
44
+ | `guideLines` | `KChartGuideLinesConfiguration` | no | - | 기존 호환 필드입니다. 새 코드는 `createGuideLineOption(...)` 사용을 권장합니다. |
45
+ | `cursorGuide` | `KChartCursorGuideConfiguration` | no | - | 기존 호환 필드입니다. 새 코드는 `createCursorLineOption(...)` 사용을 권장합니다. |
46
+ | `guideLine` | `KChartCursorGuideConfiguration` | no | - | `cursorGuide`의 legacy alias입니다. |
47
+
48
+ ## Axis Configuration
49
+
50
+ | Field | Type | Required | Description |
51
+ | --- | --- | ---: | --- |
52
+ | `field` | `keyof T & string` | yes | domain을 계산할 데이터 field입니다. |
53
+ | `type` | `'number' \| 'time' \| 'string' \| 'point'` | yes | scale 종류입니다. zoom은 `number`, `time`만 지원합니다. |
54
+ | `placement` | `'top' \| 'right' \| 'bottom' \| 'left'` | yes | axis 위치입니다. bottom/top은 x축, left/right는 y축으로 해석됩니다. |
55
+ | `domainFields` | `Array<keyof T & string>` | no | number/time domain 계산에 여러 field를 포함합니다. 캔들차트에서는 `['low', 'high']`처럼 사용합니다. |
56
+ | `min` / `max` | `number \| Date` | no | domain의 최소/최대값을 고정합니다. 지정하면 자동 padding은 적용되지 않습니다. |
57
+ | `domain` | `Array<string \| number \| Date>` | no | scale domain을 직접 지정합니다. |
58
+ | `visible` | `boolean` | no | `false`이면 axis를 숨깁니다. scale 자체는 여전히 series 계산에 사용할 수 있습니다. |
59
+ | `padding` | `number` | no | number/time domain 양끝에 비율 padding을 추가합니다. `min`, `max`가 없을 때만 적용됩니다. |
60
+ | `title` | `string` | no | axis title입니다. |
61
+ | `tickCount` | `number` | no | tick 개수 힌트입니다. |
62
+ | `tickFormat` | `(value: any) => string` | no | tick label formatter입니다. |
63
+
64
+ ## Title, Grid, Legend, Tooltip
65
+
66
+ ### `title`
67
+
68
+ | Field | Type | Default | Description |
69
+ | --- | --- | --- | --- |
70
+ | `text` | `string` | required | 제목 텍스트입니다. 빈 문자열이면 title 영역이 실질적으로 사라집니다. |
71
+ | `align` | `'left' \| 'center' \| 'right'` | implementation default | 제목 정렬입니다. |
72
+ | `color` | `string` | theme default | 제목 색상입니다. |
73
+ | `fontSize` | `number` | theme default | 제목 글자 크기입니다. |
74
+ | `fontWeight` | `number \| string` | theme default | 제목 굵기입니다. |
75
+
76
+ ### `grid`
77
+
78
+ | Field | Type | Description |
79
+ | --- | --- | --- |
80
+ | `visible` | `boolean` | 전체 grid 표시 여부입니다. |
81
+ | `x` | `boolean` | x 방향 grid line 표시 여부입니다. |
82
+ | `y` | `boolean` | y 방향 grid line 표시 여부입니다. |
83
+ | `color` | `string` | grid line 색상입니다. |
84
+ | `dasharray` | `string` | SVG `stroke-dasharray` 값입니다. |
85
+
86
+ ### `legend`
87
+
88
+ | Field | Type | Default | Description |
89
+ | --- | --- | --- | --- |
90
+ | `visible` | `boolean` | `true` | 범례 표시 여부입니다. |
91
+ | `placement` | `'top' \| 'right' \| 'bottom'` | `top` | 범례 위치입니다. |
92
+ | `itemGap` | `number` | implementation default | 범례 item 사이 간격입니다. |
93
+ | `selectable` | `boolean` | `true` style behavior | 체크박스로 series 표시/숨김을 제어할지 여부입니다. |
94
+
95
+ ### `tooltip`
96
+
97
+ | Field | Type | Description |
98
+ | --- | --- | --- |
99
+ | `visible` | `boolean` | tooltip 표시 여부입니다. |
100
+ | `formatter` | `(context) => string` | tooltip HTML/text를 직접 생성합니다. `context`에는 `data`, `series`, `x`, `y`, `color`가 들어옵니다. |
101
+
102
+ ## Animation Configuration
103
+
104
+ 차트 레벨 `animation`은 series renderer에 `animation.progress`를 전달합니다. `animation: true`로 기본 enter animation을 켤 수 있고, 세부 옵션으로 duration과 easing을 조절할 수 있습니다. 현재 1차 지원 대상은 `createLineSeries`, `createCanvasLineSeries`, `createWebglLineSeries`입니다. Custom series에서는 `render(context)`의 `context.animation.progress`를 사용해 직접 애니메이션을 구현할 수 있습니다.
105
+
106
+ ```ts
107
+ createKChart({
108
+ selector: '#chart',
109
+ data,
110
+ axes,
111
+ series,
112
+ animation: {
113
+ enabled: true,
114
+ duration: 820,
115
+ easing: 'easeOutCubic',
116
+ mode: 'enter'
117
+ }
118
+ });
119
+ ```
120
+
121
+ | Field | Type | Default | Description |
122
+ | --- | --- | --- | --- |
123
+ | `enabled` | `boolean` | `false` | animation을 켭니다. `animation: true`와 동일하게 사용할 수 있습니다. |
124
+ | `duration` | `number` | `720` | enter animation 지속 시간(ms)입니다. |
125
+ | `easing` | `'linear' \| 'easeOutCubic' \| 'easeInOutCubic'` | `easeOutCubic` | progress easing 함수입니다. |
126
+ | `mode` | `'enter' \| 'update' \| 'both'` | `enter` | 현재는 `enter` animation을 지원합니다. `update`/`both`는 향후 data transition 확장을 위한 public contract입니다. |
127
+ | `respectReducedMotion` | `boolean` | `true` | OS의 reduced motion 설정이 켜져 있으면 animation을 생략합니다. |
128
+
129
+ ## Zoom Configuration
130
+
131
+ 차트 레벨 zoom은 `number` 또는 `time` axis domain을 갱신한 뒤 기존 render pipeline을 다시 실행합니다. `string`/`point` 축은 순서형 축이라 zoom 대상에서 제외됩니다.
132
+
133
+ | Field | Type | Default | Description |
134
+ | --- | --- | --- | --- |
135
+ | `enabled` | `boolean` | `false` | zoom 기능을 켭니다. |
136
+ | `mode` | `'wheel' \| 'select' \| 'both'` | implementation default | wheel/pan, drag selection zoom, 둘 다 중 어떤 입력을 사용할지 정합니다. |
137
+ | `direction` | `'x' \| 'y' \| 'xy'` | implementation default | zoom 대상 축 방향입니다. 대용량 time-series는 보통 `'x'`를 사용합니다. |
138
+ | `scaleExtent` | `[number, number]` | implementation default | 최소/최대 zoom 배율입니다. |
139
+ | `wheelZoom` | `boolean \| KChartWheelZoomConfiguration` | enabled by mode | PC wheel/trackpad zoom 입력 설정입니다. |
140
+ | `gestureZoom` | `boolean \| KChartGestureZoomConfiguration` | enabled by mode | 모바일 touch/pinch 입력 설정입니다. |
141
+ | `resetOnDoubleClick` | `boolean` | `true` style behavior | 더블클릭으로 zoom reset을 허용할지 정합니다. |
142
+ | `onZoom` | `(context) => void` | - | zoom 후 현재 `xDomain`, `yDomain`, `transform`을 받을 수 있습니다. |
143
+
144
+ `wheelZoom` 세부 옵션:
145
+
146
+ | Field | Type | Default | Description |
147
+ | --- | --- | --- | --- |
148
+ | `enabled` | `boolean` | `true` | wheel zoom 입력을 켭니다. |
149
+ | `devices` | `'pc' \| 'mobile' \| 'all'` | `pc` | 어떤 입력 장치에서 반응할지 정합니다. |
150
+ | `sensitivity` | `number` | `1` | wheel zoom 민감도입니다. 0보다 커야 합니다. |
151
+
152
+ `gestureZoom` 세부 옵션:
153
+
154
+ | Field | Type | Default | Description |
155
+ | --- | --- | --- | --- |
156
+ | `enabled` | `boolean` | `true` | touch gesture zoom 입력을 켭니다. |
157
+ | `devices` | `'pc' \| 'mobile' \| 'all'` | `mobile` | 어떤 입력 장치에서 반응할지 정합니다. |
158
+ | `minTouches` | `number` | `1` | gesture 처리에 필요한 최소 touch 수입니다. |
159
+
160
+ ## Series Common Contract
161
+
162
+ 모든 series factory는 최종적으로 `KChartSeries<T>`를 반환합니다.
163
+
164
+ | Field | Type | Description |
165
+ | --- | --- | --- |
166
+ | `selector` | `string` | series의 DOM/canvas class, legend key, hidden key로 사용됩니다. 같은 chart 안에서 고유해야 합니다. |
167
+ | `displayName` | `string` | legend와 tooltip에 표시할 이름입니다. 없으면 `selector`를 사용합니다. |
168
+ | `xField` / `yField` | `keyof T & string` | 기본 tooltip, scale 선택, downsample에 쓰이는 field입니다. |
169
+ | `color` | `string` | series 색상입니다. 없으면 chart `colors` 팔레트에서 할당됩니다. |
170
+ | `downsample` | `boolean \| KChartDownsampleConfiguration<T>` | line 계열 renderer에서 LTTB downsampling을 적용합니다. |
171
+ | `render(context)` | `function` | 실제 렌더링 함수입니다. custom series의 핵심 확장 지점입니다. |
172
+ | `tooltip(context)` | `function` | custom tooltip hit-test를 구현할 수 있습니다. |
173
+ | `clearTooltip(context)` | `function` | hover 종료 시 series highlight를 되돌릴 수 있습니다. |
174
+ | `destroy(context)` | `function` | chart destroy/update 시 canvas, WebGL resource, animation frame 등을 정리합니다. |
175
+
176
+ ## Built-In Series Configuration
177
+
178
+ ### SVG Line: `createLineSeries`
179
+
180
+ | Field | Type | Default | Description |
181
+ | --- | --- | --- | --- |
182
+ | `selector` | `string` | required | series id/class입니다. |
183
+ | `displayName` | `string` | `selector` | legend/tooltip 이름입니다. |
184
+ | `xField` / `yField` | `keyof T & string` | required | line 좌표 field입니다. |
185
+ | `color` | `string` | chart color | stroke 색상입니다. |
186
+ | `strokeWidth` | `number` | `2` | SVG path stroke width입니다. |
187
+ | `curve` | `boolean` | `false` | `true`이면 `curveMonotoneX`를 사용합니다. |
188
+ | `dot` | `boolean \| { radius; fill; stroke }` | `false` | 각 point에 SVG circle을 표시합니다. |
189
+ | `downsample` | `boolean \| object` | disabled | LTTB를 적용합니다. |
190
+
191
+ ### Canvas Line: `createCanvasLineSeries`
192
+
193
+ | Field | Type | Default | Description |
194
+ | --- | --- | --- | --- |
195
+ | `selector` | `string` | required | series id입니다. |
196
+ | `xField` / `yField` | `keyof T & string` | required | line 좌표 field입니다. |
197
+ | `color` | `string` | chart color | stroke 색상입니다. |
198
+ | `lineWidth` | `number` | `2` | Canvas line width입니다. |
199
+ | `canvasName` | `string` | `selector` | canvas layer 이름입니다. 여러 series가 같은 canvas를 공유할 때 지정합니다. |
200
+ | `downsample` | `boolean \| object` | disabled | LTTB를 적용합니다. |
201
+ | `asyncRender` | `KChartAsyncRenderConfiguration` | disabled | OffscreenCanvas + Worker line draw를 사용합니다. |
202
+
203
+ ### Canvas Point: `createCanvasPointSeries`
204
+
205
+ | Field | Type | Default | Description |
206
+ | --- | --- | --- | --- |
207
+ | `selector` | `string` | required | series id입니다. |
208
+ | `xField` / `yField` | `keyof T & string` | required | point 좌표 field입니다. |
209
+ | `color` | `string` | chart color | fill fallback 색상입니다. |
210
+ | `radius` | `number \| (point) => number` | `3` | point 반지름입니다. |
211
+ | `fill` | `string` | `color` | point fill 색상입니다. |
212
+ | `stroke` | `string` | `rgba(255, 255, 255, 0.78)` | point stroke 색상입니다. |
213
+ | `strokeWidth` | `number` | `1.5` | point stroke width입니다. |
214
+ | `canvasName` | `string` | `selector` | canvas layer 이름입니다. |
215
+
216
+ ### Canvas Candlestick: `createCanvasCandlestickSeries`
217
+
218
+ | Field | Type | Default | Description |
219
+ | --- | --- | --- | --- |
220
+ | `selector` | `string` | required | series id입니다. |
221
+ | `xField` | `keyof T & string` | required | candle x 위치 field입니다. |
222
+ | `openField` / `highField` / `lowField` / `closeField` | `keyof T & string` | required | OHLC 값 field입니다. |
223
+ | `colorMode` | `'open-close' \| 'previous-close'` | `open-close` | 색상 기준입니다. 전일 종가 기준이면 `previous-close`를 사용합니다. |
224
+ | `previousCloseField` | `keyof T & string` | previous data close | `previous-close` 모드에서 비교 기준 field입니다. 없으면 이전 row의 close를 사용합니다. |
225
+ | `upColor` | `string` | `#22c55e` | 상승 candle 색상입니다. |
226
+ | `downColor` | `string` | `#ef4444` | 하락 candle 색상입니다. |
227
+ | `neutralColor` | `string` | chart color | 보합 또는 계산 불가 색상입니다. |
228
+ | `wickColor` | `string` | candle color | wick stroke 색상입니다. |
229
+ | `borderColor` | `string` | candle color | body border 색상입니다. |
230
+ | `candleWidth` | `number \| ({ data, xScale, plotSize }) => number` | auto | candle body width입니다. |
231
+ | `minCandleWidth` | `number` | `3` | 자동 width 최소값입니다. |
232
+ | `maxCandleWidth` | `number` | `18` | 자동 width 최대값입니다. |
233
+ | `strokeWidth` | `number` | `1.4` | wick/body stroke width입니다. |
234
+ | `canvasName` | `string` | `selector` | canvas layer 이름입니다. |
235
+
236
+ ### WebGL Line: `createWebglLineSeries`
237
+
238
+ | Field | Type | Default | Description |
239
+ | --- | --- | --- | --- |
240
+ | `selector` | `string` | required | series id입니다. |
241
+ | `xField` / `yField` | `keyof T & string` | required | line 좌표 field입니다. |
242
+ | `color` | `string` | chart color | line 색상입니다. |
243
+ | `lineWidth` | `number` | `1` | WebGL line width입니다. 브라우저/드라이버에 따라 1보다 큰 값이 제한될 수 있습니다. |
244
+ | `canvasName` | `string` | `selector` | WebGL canvas layer 이름입니다. |
245
+ | `downsample` | `boolean \| object` | disabled | LTTB를 적용합니다. |
246
+ | `asyncRender` | `KChartAsyncRenderConfiguration` | disabled | OffscreenCanvas + Worker line draw를 사용합니다. |
247
+
248
+ ### WebGL Point: `createWebglPointSeries`
249
+
250
+ | Field | Type | Default | Description |
251
+ | --- | --- | --- | --- |
252
+ | `selector` | `string` | required | series id입니다. |
253
+ | `xField` / `yField` | `keyof T & string` | required | point 좌표 field입니다. |
254
+ | `color` | `string` | chart color | point 색상입니다. |
255
+ | `pointSize` | `number \| (point) => number` | `8` | `gl_PointSize`로 전달되는 point 크기입니다. |
256
+ | `canvasName` | `string` | `selector` | WebGL canvas layer 이름입니다. |
257
+
258
+ WebGL point는 현재 interleaved buffer `[x, y, size]` 구조로 GPU에 전달합니다. Worker async path는 line series에만 구현되어 있습니다.
259
+
260
+ ### SVG Globe: `createSvgGlobeSeries`
261
+
262
+ | Field | Type | Default | Description |
263
+ | --- | --- | --- | --- |
264
+ | `latField` / `lonField` | `keyof T & string` | required | 일반 위도/경도 좌표입니다. 내부에서 `projection([lon, lat])`로 변환합니다. |
265
+ | `labelField` | `keyof T & string` | - | marker label field입니다. |
266
+ | `initialRotate` | `[number, number, number?]` | implementation default | 초기 지구본 회전값입니다. |
267
+ | `draggable` | `boolean` | `true` | mouse drag로 지구본을 회전할지 정합니다. |
268
+ | `globeScale` | `number` | auto | 지구본 기본 scale입니다. |
269
+ | `zoom` | `boolean \| KChartGlobeZoomConfiguration` | disabled | wheel/pinch/control zoom을 켭니다. |
270
+ | `drilldown` | `boolean \| KChartGlobeDrilldownConfiguration<T>` | disabled | marker click 또는 zoom threshold 기반 focus/map 전환입니다. |
271
+ | `landMode` | `'land' \| 'countries'` | `land` | land layer를 단일 land 또는 국가 feature 단위로 그릴지 정합니다. |
272
+ | `landGeoJson` | `any \| any[]` | world-atlas land | custom GeoJSON입니다. |
273
+ | `markerRadius` | `number \| (point) => number` | implementation default | marker 크기입니다. |
274
+ | `markerColor` | `string \| (point) => string` | implementation default | marker 색상입니다. |
275
+ | `onMarkerClick` | `(context) => void` | - | marker click callback입니다. `data`, `lat`, `lon`, `x`, `y`, `event`를 받습니다. |
276
+
277
+ ## Downsampling Configuration
278
+
279
+ `createLineSeries`, `createCanvasLineSeries`, `createWebglLineSeries`에서 사용할 수 있습니다.
280
+
281
+ | Field | Type | Default | Description |
282
+ | --- | --- | --- | --- |
283
+ | `enabled` | `boolean` | `true` when object exists | false이면 downsampling을 끕니다. |
284
+ | `threshold` | `number \| (context) => number` | plot width | 줄이고자 하는 목표 point 수입니다. 보통 chart plot width를 사용합니다. |
285
+ | `xAccessor` | `(point) => number` | field 기반 | LTTB x 값 추출 함수입니다. |
286
+ | `yAccessor` | `(point) => number` | field 기반 | LTTB y 값 추출 함수입니다. |
287
+
288
+ ## Worker Rendering
289
+
290
+ KChart의 Worker 렌더링은 opt-in입니다. 현재 파악된 실제 동작 범위는 다음과 같습니다.
291
+
292
+ - 지원 series: `createCanvasLineSeries`, `createWebglLineSeries`
293
+ - 지원 작업: line draw 호출을 OffscreenCanvas + Web Worker로 이동
294
+ - main thread에 남는 작업: axis/scale/layout 계산, legend/tooltip DOM, `data -> Float32Array` point 변환
295
+ - fallback: `workerFactory`가 없거나 `transferControlToOffscreen`을 지원하지 않거나 worker 생성이 실패하면 main-thread renderer로 실행
296
+ - 미지원: `createWebglPointSeries`, candlestick, SVG series, tooltip hit-test의 worker 이동
297
+
298
+ ```ts
299
+ // kchart-render.worker.ts
300
+ import { startKChartRenderWorker } from '@keneth80/k-chart';
301
+
302
+ startKChartRenderWorker();
303
+ ```
304
+
305
+ ```ts
306
+ createWebglLineSeries<Point>({
307
+ selector: 'trace',
308
+ xField: 'x',
309
+ yField: 'signal',
310
+ asyncRender: {
311
+ enabled: true,
312
+ workerFactory: () => new Worker(
313
+ new URL('./kchart-render.worker.ts', import.meta.url),
314
+ { type: 'module' }
315
+ )
316
+ }
317
+ });
318
+ ```
319
+
320
+ 현재 demo에서는 `Canvas BigData` 50k line과 `WebGL BigData` 120k line examples에 `asyncRender`가 적용되어 있습니다. 브라우저 콘솔에서 `[KChart Demo] creating render worker #...` 로그가 보이면 worker가 생성된 것입니다.
321
+
322
+ StackBlitz에서 data fetch와 worker 실행 여부를 같이 확인하려면
323
+ [`examples/stackblitz-worker-json-line`](../examples/stackblitz-worker-json-line)를 참고합니다.
324
+ 이 예제는 `/data/large-line.json`을 `fetch()`로 읽고, `workerFactory` 호출 횟수와
325
+ OffscreenCanvas 지원 여부를 화면에 표시합니다.
326
+
327
+ ## Option Factories
328
+
329
+ 새 코드에서는 chart root field보다 option factory 사용을 권장합니다.
330
+
331
+ ```ts
332
+ createKChart({
333
+ selector: '#chart',
334
+ data,
335
+ axes,
336
+ series,
337
+ options: [
338
+ createSpecAreaOption([{ start: 2, end: 4, label: 'STEP 01' }]),
339
+ createGuideLineOption({ x: [{ value: 3, label: 'A' }] }),
340
+ createCursorLineOption(),
341
+ createTooltipNoteOption()
342
+ ]
343
+ });
344
+ ```
345
+
346
+ ### Spec Area: `createSpecAreaOption`
347
+
348
+ | Field | Type | Default | Description |
349
+ | --- | --- | --- | --- |
350
+ | `visible` | `boolean` | `true` | 전체 option 또는 area별 표시 여부입니다. |
351
+ | `start` / `end` | `number \| Date \| string` | required | x축 기준 영역 시작/끝입니다. |
352
+ | `color` | `string` | `rgba(249, 225, 250, 0.22)` | 영역 fill 색상입니다. |
353
+ | `label` | `string` | - | plot 상단에 표시할 영역 label입니다. |
354
+
355
+ ### Fixed Guide Line: `createGuideLineOption`
356
+
357
+ | Field | Type | Default | Description |
358
+ | --- | --- | --- | --- |
359
+ | `visible` | `boolean` | `true` | 전체 option 또는 line별 표시 여부입니다. |
360
+ | `x` / `y` | `KChartFixedGuideLine[]` | `[]` | x축 또는 y축 기준 고정 guide line입니다. |
361
+ | `value` | `number \| Date \| string` | required | line 위치 값입니다. |
362
+ | `label` | `string` | - | line label입니다. |
363
+ | `color` | `string` | `rgba(248, 251, 255, 0.46)` | line과 label stroke 색상입니다. |
364
+ | `width` | `number` | `1` | line width입니다. |
365
+ | `dasharray` | `string` | `4 6` | SVG dash pattern입니다. |
366
+ | `labelColor` | `string` | `#edf3f8` | label text 색상입니다. |
367
+ | `labelBackground` | `string` | `rgba(10, 14, 20, 0.84)` | label 배경색입니다. |
368
+
369
+ ### Cursor Line: `createCursorLineOption`
370
+
371
+ | Field | Type | Default | Description |
372
+ | --- | --- | --- | --- |
373
+ | `visible` | `boolean` | `true` | cursor guide 표시 여부입니다. |
374
+ | `color` | `string` | implementation default | cursor line 색상입니다. |
375
+ | `markerRadius` | `number` | implementation default | cursor marker 반지름입니다. |
376
+ | `valueFormat` | `(value) => string` | - | 공통 value formatter입니다. |
377
+ | `xFormat` | `(value) => string` | - | x축 value formatter입니다. |
378
+
379
+ ### Tooltip Note: `createTooltipNoteOption`
380
+
381
+ | Field | Type | Default | Description |
382
+ | --- | --- | --- | --- |
383
+ | `enabled` | `boolean` | `true` | tooltip pin 기능을 켭니다. |
384
+ | `maxNotes` | `number` | `8` | 고정 가능한 note 최대 개수입니다. 초과하면 오래된 note가 제거됩니다. |
385
+ | `pinButtonLabel` | `string` | `Pin` | tooltip 안 pin 버튼 label입니다. |
386
+ | `notePlaceholder` | `string` | `Add a note...` | textarea placeholder입니다. |
387
+ | `onChange` | `(notes) => void` | - | note 추가/수정/삭제 시 호출됩니다. |
388
+
389
+ ## Configuration Checklist
390
+
391
+ - x축이 문자열 category라면 chart zoom은 켜지 않는 것이 좋습니다. 현재 zoom은 `number`/`time` 축 중심입니다.
392
+ - 대용량 line은 `createWebglLineSeries` + `downsample` + `asyncRender` 조합부터 검토합니다.
393
+ - Canvas/WebGL series는 `canvasName`을 같게 주면 layer를 공유할 수 있지만, clear timing이 겹칠 수 있으므로 같은 renderer끼리 의도적으로만 공유합니다.
394
+ - OHLC chart는 y axis에 `domainFields: ['low', 'high']`를 넣어 wick이 잘리지 않게 합니다.
395
+ - 지구본/지도/Three.js/Cesium/MapLibre는 기능은 제공하지만, 외부 tile/provider/API key와 license는 애플리케이션에서 관리해야 합니다.
@@ -4,9 +4,12 @@
4
4
 
5
5
  The root package remains backward compatible. Internally, implementation is
6
6
  separated into `core`, `series`, `options`, `worker`, and `utils` modules.
7
+ If you need a field-by-field option dictionary, see
8
+ [Configuration Reference](configuration-reference.md).
7
9
 
8
10
  ```ts
9
11
  import {createKChart} from '@keneth80/k-chart/core';
12
+ import {createLineChart, chartConfig} from '@keneth80/k-chart/presets';
10
13
  import {
11
14
  createLineSeries,
12
15
  createCanvasLineSeries,
@@ -20,9 +23,10 @@ import {
20
23
  } from '@keneth80/k-chart/options';
21
24
  ```
22
25
 
23
- Series implementations depend on shared core contracts. The core runtime does
24
- not contain concrete line, point, candlestick, WebGL, or globe series
25
- implementations.
26
+ Preset helpers are a thin beginner-friendly layer over the same core
27
+ configuration. Series implementations depend on shared core contracts. The core
28
+ runtime does not contain concrete line, point, candlestick, WebGL, or globe
29
+ series implementations.
26
30
 
27
31
  ## Goal
28
32
 
@@ -34,7 +38,11 @@ KChart의 새 public API는 class adapter가 아니라 class-free runtime입니
34
38
 
35
39
  ```ts
36
40
  import {
41
+ chartConfig,
42
+ createColumnChart,
37
43
  createKChart,
44
+ createLineChart,
45
+ createPieChart,
38
46
  createCursorLineOption,
39
47
  createGuideLineOption,
40
48
  createLineSeries,
@@ -55,6 +63,67 @@ import {
55
63
  내부 import 호환성을 위한 barrel입니다. 기존 class 기반 구현은 패키지 API로
56
64
  내보내지 않습니다.
57
65
 
66
+ ## Beginner Preset API
67
+
68
+ Preset API는 축과 series boilerplate를 숨기고, 내부적으로 동일한 `KChartConfiguration`을 만들어 `createKChart(...)`에 전달합니다.
69
+
70
+ ```ts
71
+ import {createLineChart} from '@keneth80/k-chart';
72
+
73
+ type SalesPoint = {
74
+ month: string;
75
+ revenue: number;
76
+ };
77
+
78
+ createLineChart<SalesPoint>({
79
+ selector: '#chart',
80
+ data: [
81
+ {month: 'Jan', revenue: 42},
82
+ {month: 'Feb', revenue: 48},
83
+ {month: 'Mar', revenue: 45}
84
+ ],
85
+ x: {field: 'month', type: 'point', title: 'Month'},
86
+ y: {field: 'revenue', type: 'number', title: 'Revenue'},
87
+ title: 'Revenue Trend',
88
+ animation: true
89
+ });
90
+ ```
91
+
92
+ 제공되는 얇은 preset 함수:
93
+
94
+ | Function | Purpose |
95
+ | --- | --- |
96
+ | `createLineChart(options)` | SVG/Canvas/WebGL line chart를 빠르게 생성합니다. `renderer: 'canvas' \| 'webgl'`로 renderer를 바꿀 수 있습니다. |
97
+ | `createColumnChart(options)` | category/point x축 기반 column chart를 생성합니다. |
98
+ | `createPieChart(options)` | `label`, `value` field만 지정해 pie chart를 생성합니다. |
99
+ | `createDoughnutChart(options)` | pie chart와 같은 옵션을 쓰고 기본 inner radius를 적용합니다. |
100
+
101
+ ## Chart Builder API
102
+
103
+ 여러 설정을 단계적으로 조립하고 싶다면 `chartConfig(data)` builder를 사용할 수 있습니다. `build()`는 advanced configuration을 반환하고, `render()`는 즉시 chart를 생성합니다.
104
+
105
+ ```ts
106
+ import {chartConfig} from '@keneth80/k-chart';
107
+
108
+ const config = chartConfig(data)
109
+ .x('month', 'point', {title: 'Month'})
110
+ .y('orders', 'number', {title: 'Orders'})
111
+ .column({color: '#56d08f'})
112
+ .tooltip()
113
+ .animation()
114
+ .build({selector: '#chart'});
115
+
116
+ const chart = chartConfig(data)
117
+ .selector('#chart')
118
+ .title('Orders By Month')
119
+ .x('month', 'point')
120
+ .y('orders', 'number')
121
+ .column()
122
+ .render();
123
+ ```
124
+
125
+ Builder는 `series(...)`와 `option(...)`도 제공하므로, 초보자용 흐름에서 시작해 기존 `createLineSeries(...)`, `createSpecAreaOption(...)` 같은 고급 함수와 섞어 사용할 수 있습니다.
126
+
58
127
  ## Controller
59
128
 
60
129
  ```ts
@@ -331,6 +400,33 @@ import { downsampleLTTB } from '@keneth80/k-chart';
331
400
  const sampled = downsampleLTTB(data, 1000, (point) => point.x, (point) => point.signal);
332
401
  ```
333
402
 
403
+ ### Animation
404
+
405
+ 차트 레벨의 `animation` 옵션은 series renderer에 `animation.progress`를 전달합니다. `animation: true`로 기본 enter animation을 켤 수 있고, 세부 옵션으로 duration/easing을 조절할 수 있습니다. 현재 기본 지원 renderer는 `createLineSeries`, `createCanvasLineSeries`, `createWebglLineSeries`입니다.
406
+
407
+ ```ts
408
+ createKChart<Point>({
409
+ selector: '#chart',
410
+ data,
411
+ axes: [
412
+ { field: 'x', type: 'number', placement: 'bottom' },
413
+ { field: 'signal', type: 'number', placement: 'left' }
414
+ ],
415
+ series: [
416
+ createLineSeries({ selector: 'signal', xField: 'x', yField: 'signal' })
417
+ ],
418
+ animation: {
419
+ enabled: true,
420
+ duration: 820,
421
+ easing: 'easeOutCubic',
422
+ mode: 'enter',
423
+ respectReducedMotion: true
424
+ }
425
+ });
426
+ ```
427
+
428
+ Custom series에서는 `render(context)` 안에서 `context.animation.progress`를 읽어 직접 opacity, scale, arc sweep, draw count 등을 조절할 수 있습니다. Demo의 column, stacked column, plot point, radial, pie, doughnut renderer가 같은 방식으로 구현되어 있습니다. 대용량 WebGL chart는 animation 중 매 프레임 렌더링하므로 필요한 화면에서만 opt-in으로 켜는 것을 권장합니다.
429
+
334
430
  ### Zoom
335
431
 
336
432
  차트 레벨의 `zoom` 옵션은 number/time 축의 domain을 갱신하고 기존 렌더 파이프라인을 다시 실행합니다. 별도 series API 없이 SVG, Canvas, WebGL renderer가 같은 확대 상태를 공유합니다.
@@ -392,6 +488,10 @@ createWebglLineSeries<Point>({
392
488
 
393
489
  OffscreenCanvas를 지원하지 않거나 worker 생성에 실패하면 기존 메인 스레드 렌더러로 fallback됩니다.
394
490
 
491
+ JSON 데이터를 `fetch()`로 읽고 worker 생성 여부를 화면에서 확인하는 전체 예제는
492
+ [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)를 참고하세요.
493
+ 이 예제는 API/data URL과 worker module URL이 서로 다른 역할이라는 점을 보여줍니다.
494
+
395
495
  ## Display Options
396
496
 
397
497
  ```ts
@@ -0,0 +1,23 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>KChart Canvas Candlestick Basic</title>
7
+ </head>
8
+ <body>
9
+ <main class="page-shell">
10
+ <section class="intro">
11
+ <p class="eyebrow">StackBlitz starter</p>
12
+ <h1>KChart Canvas Candlestick</h1>
13
+ <p>Edit <code>src/main.ts</code> to change OHLC data, colors, and zoom behavior.</p>
14
+ </section>
15
+
16
+ <section class="chart-panel">
17
+ <div id="chart"></div>
18
+ </section>
19
+ </main>
20
+
21
+ <script type="module" src="/src/main.ts"></script>
22
+ </body>
23
+ </html>