katucharts.js 0.2.1

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 (200) hide show
  1. package/LICENSE +106 -0
  2. package/README.md +1100 -0
  3. package/dist/__vite-optional-peer-dep_jspdf_katucharts-BDMct_Gn.js +4 -0
  4. package/dist/accessibility/A11yModule.d.ts +26 -0
  5. package/dist/axis/Axis.d.ts +140 -0
  6. package/dist/axis/AxisCoordinator.d.ts +38 -0
  7. package/dist/bio.d.ts +22 -0
  8. package/dist/components/Credits.d.ts +38 -0
  9. package/dist/components/Crosshair.d.ts +15 -0
  10. package/dist/components/DataLabels.d.ts +7 -0
  11. package/dist/components/ExportButton.d.ts +27 -0
  12. package/dist/components/Legend.d.ts +53 -0
  13. package/dist/components/TitleRenderer.d.ts +19 -0
  14. package/dist/components/Tooltip.d.ts +61 -0
  15. package/dist/core/Chart.d.ts +156 -0
  16. package/dist/core/EventBus.d.ts +14 -0
  17. package/dist/core/InteractionController.d.ts +62 -0
  18. package/dist/core/OptionsParser.d.ts +61 -0
  19. package/dist/core/Registry.d.ts +27 -0
  20. package/dist/core/SVGRenderer.d.ts +48 -0
  21. package/dist/core/ScrollablePlotOverlay.d.ts +31 -0
  22. package/dist/core/StackComputer.d.ts +25 -0
  23. package/dist/core/StateManager.d.ts +21 -0
  24. package/dist/core/UpdateScheduler.d.ts +28 -0
  25. package/dist/core/animationConstants.d.ts +20 -0
  26. package/dist/core/chartTypes.d.ts +46 -0
  27. package/dist/core/registerAll.d.ts +4 -0
  28. package/dist/core/registerBio.d.ts +4 -0
  29. package/dist/core/registerCore.d.ts +4 -0
  30. package/dist/core/registerFinance.d.ts +4 -0
  31. package/dist/core/registerFinancial.d.ts +4 -0
  32. package/dist/core/registerFlow.d.ts +4 -0
  33. package/dist/core/registerGeneral.d.ts +4 -0
  34. package/dist/datatable/DataTable.d.ts +162 -0
  35. package/dist/datatable/DataTableDefaults.d.ts +7 -0
  36. package/dist/datatable/api/TableApi.d.ts +35 -0
  37. package/dist/datatable/columns/ColumnDef.d.ts +16 -0
  38. package/dist/datatable/columns/ColumnManager.d.ts +31 -0
  39. package/dist/datatable/data/DataProcessor.d.ts +46 -0
  40. package/dist/datatable/data/DataSource.d.ts +26 -0
  41. package/dist/datatable/editing/CellEditor.d.ts +29 -0
  42. package/dist/datatable/export/TableExport.d.ts +23 -0
  43. package/dist/datatable/locales/en.d.ts +9 -0
  44. package/dist/datatable/locales/es.d.ts +6 -0
  45. package/dist/datatable/locales/index.d.ts +22 -0
  46. package/dist/datatable/locales/pt-BR.d.ts +6 -0
  47. package/dist/datatable/locales/resolveLocale.d.ts +16 -0
  48. package/dist/datatable/locales/zh.d.ts +6 -0
  49. package/dist/datatable/render/CellRenderer.d.ts +24 -0
  50. package/dist/datatable/render/HeaderRenderer.d.ts +51 -0
  51. package/dist/datatable/render/PaginationRenderer.d.ts +26 -0
  52. package/dist/datatable/render/SearchRenderer.d.ts +21 -0
  53. package/dist/datatable/render/TableRenderer.d.ts +81 -0
  54. package/dist/datatable/render/ToolbarRenderer.d.ts +34 -0
  55. package/dist/datatable/render/icons.d.ts +24 -0
  56. package/dist/datatable/render/popover.d.ts +15 -0
  57. package/dist/datatable/selection/SelectionManager.d.ts +29 -0
  58. package/dist/datatable/themes/TableTheme.d.ts +36 -0
  59. package/dist/datatable/themes/styleSheet.d.ts +16 -0
  60. package/dist/datatable.d.ts +19 -0
  61. package/dist/export/ChartExporter.d.ts +50 -0
  62. package/dist/export/Export.d.ts +76 -0
  63. package/dist/finance.d.ts +49 -0
  64. package/dist/index.d.ts +67 -0
  65. package/dist/indicators/Indicator.d.ts +23 -0
  66. package/dist/indicators/expandIndicators.d.ts +18 -0
  67. package/dist/indicators/moving-averages/DEMA.d.ts +10 -0
  68. package/dist/indicators/moving-averages/EMA.d.ts +12 -0
  69. package/dist/indicators/moving-averages/SMA.d.ts +11 -0
  70. package/dist/indicators/moving-averages/TEMA.d.ts +10 -0
  71. package/dist/indicators/moving-averages/WMA.d.ts +12 -0
  72. package/dist/indicators/oscillators/CCI.d.ts +11 -0
  73. package/dist/indicators/oscillators/MACD.d.ts +20 -0
  74. package/dist/indicators/oscillators/Momentum.d.ts +10 -0
  75. package/dist/indicators/oscillators/ROC.d.ts +10 -0
  76. package/dist/indicators/oscillators/RSI.d.ts +11 -0
  77. package/dist/indicators/oscillators/Stochastic.d.ts +20 -0
  78. package/dist/indicators/registry.d.ts +9 -0
  79. package/dist/indicators/trend/ADX.d.ts +11 -0
  80. package/dist/indicators/trend/IchimokuCloud.d.ts +14 -0
  81. package/dist/indicators/trend/PSAR.d.ts +11 -0
  82. package/dist/indicators/util.d.ts +8 -0
  83. package/dist/indicators/volatility/ATR.d.ts +11 -0
  84. package/dist/indicators/volatility/BollingerBands.d.ts +11 -0
  85. package/dist/indicators/volume/OBV.d.ts +11 -0
  86. package/dist/indicators/volume/VBP.d.ts +12 -0
  87. package/dist/indicators/volume/VWAP.d.ts +12 -0
  88. package/dist/interaction/Drilldown.d.ts +29 -0
  89. package/dist/interaction/HoverManager.d.ts +47 -0
  90. package/dist/interaction/Zoom.d.ts +68 -0
  91. package/dist/katucharts-bio.es.js +5861 -0
  92. package/dist/katucharts-bio.umd.js +1 -0
  93. package/dist/katucharts-datatable.es.js +3363 -0
  94. package/dist/katucharts-datatable.umd.js +296 -0
  95. package/dist/katucharts-finance.es.js +4364 -0
  96. package/dist/katucharts-finance.umd.js +1 -0
  97. package/dist/katucharts-react.es.js +35 -0
  98. package/dist/katucharts-react.umd.js +1 -0
  99. package/dist/katucharts.es.js +20531 -0
  100. package/dist/katucharts.umd.js +9 -0
  101. package/dist/layout/LayoutEngine.d.ts +44 -0
  102. package/dist/license/LicenseManager.d.ts +63 -0
  103. package/dist/options/defaults.d.ts +5 -0
  104. package/dist/react/KatuChartsReact.d.ts +16 -0
  105. package/dist/react.d.ts +2 -0
  106. package/dist/responsive/ResponsiveEngine.d.ts +15 -0
  107. package/dist/series/BaseSeries.d.ts +186 -0
  108. package/dist/series/bioinformatics/CircosChart.d.ts +4 -0
  109. package/dist/series/bioinformatics/ClusteredHeatmapChart.d.ts +22 -0
  110. package/dist/series/bioinformatics/ForestPlotChart.d.ts +21 -0
  111. package/dist/series/bioinformatics/KaplanMeierChart.d.ts +22 -0
  112. package/dist/series/bioinformatics/ManhattanChart.d.ts +34 -0
  113. package/dist/series/bioinformatics/PCoAChart.d.ts +22 -0
  114. package/dist/series/bioinformatics/PhyloTreeChart.d.ts +27 -0
  115. package/dist/series/bioinformatics/SequenceLogoChart.d.ts +21 -0
  116. package/dist/series/bioinformatics/ViolinChart.d.ts +23 -0
  117. package/dist/series/bioinformatics/VolcanoChart.d.ts +28 -0
  118. package/dist/series/bioinformatics/circos/CircosChart.d.ts +20 -0
  119. package/dist/series/bioinformatics/circos/CircosColorScales.d.ts +6 -0
  120. package/dist/series/bioinformatics/circos/CircosComparativeChart.d.ts +41 -0
  121. package/dist/series/bioinformatics/circos/CircosHeatmapChart.d.ts +31 -0
  122. package/dist/series/bioinformatics/circos/CircosLayoutEngine.d.ts +37 -0
  123. package/dist/series/bioinformatics/circos/CircosRules.d.ts +6 -0
  124. package/dist/series/bioinformatics/circos/CircosSpiralChart.d.ts +39 -0
  125. package/dist/series/bioinformatics/circos/CircosTypes.d.ts +131 -0
  126. package/dist/series/bioinformatics/circos/tracks/AreaTrackRenderer.d.ts +7 -0
  127. package/dist/series/bioinformatics/circos/tracks/ConnectorTrackRenderer.d.ts +7 -0
  128. package/dist/series/bioinformatics/circos/tracks/GlyphTrackRenderer.d.ts +7 -0
  129. package/dist/series/bioinformatics/circos/tracks/HeatmapTrackRenderer.d.ts +7 -0
  130. package/dist/series/bioinformatics/circos/tracks/HighlightTrackRenderer.d.ts +6 -0
  131. package/dist/series/bioinformatics/circos/tracks/HistogramTrackRenderer.d.ts +7 -0
  132. package/dist/series/bioinformatics/circos/tracks/LineTrackRenderer.d.ts +7 -0
  133. package/dist/series/bioinformatics/circos/tracks/LinkTrackRenderer.d.ts +8 -0
  134. package/dist/series/bioinformatics/circos/tracks/LollipopTrackRenderer.d.ts +9 -0
  135. package/dist/series/bioinformatics/circos/tracks/RibbonTrackRenderer.d.ts +9 -0
  136. package/dist/series/bioinformatics/circos/tracks/ScatterTrackRenderer.d.ts +7 -0
  137. package/dist/series/bioinformatics/circos/tracks/StackTrackRenderer.d.ts +7 -0
  138. package/dist/series/bioinformatics/circos/tracks/TextTrackRenderer.d.ts +8 -0
  139. package/dist/series/bioinformatics/circos/tracks/TileTrackRenderer.d.ts +7 -0
  140. package/dist/series/bioinformatics/circos/tracks/TrackAxesRenderer.d.ts +6 -0
  141. package/dist/series/bioinformatics/circos/tracks/TrackBackgroundRenderer.d.ts +5 -0
  142. package/dist/series/cartesian/AreaChart.d.ts +33 -0
  143. package/dist/series/cartesian/BoxPlotChart.d.ts +24 -0
  144. package/dist/series/cartesian/BubbleChart.d.ts +34 -0
  145. package/dist/series/cartesian/ColumnChart.d.ts +37 -0
  146. package/dist/series/cartesian/LineChart.d.ts +28 -0
  147. package/dist/series/cartesian/ScatterChart.d.ts +20 -0
  148. package/dist/series/cartesian/SplineChart.d.ts +9 -0
  149. package/dist/series/cartesian/WaterfallChart.d.ts +25 -0
  150. package/dist/series/financial/AreaRangeChart.d.ts +24 -0
  151. package/dist/series/financial/BaselineChart.d.ts +20 -0
  152. package/dist/series/financial/CandlestickChart.d.ts +55 -0
  153. package/dist/series/financial/ColumnRangeChart.d.ts +16 -0
  154. package/dist/series/financial/FlagsChart.d.ts +34 -0
  155. package/dist/series/financial/HeikinAshiChart.d.ts +11 -0
  156. package/dist/series/financial/HollowCandlestickChart.d.ts +17 -0
  157. package/dist/series/financial/KagiChart.d.ts +23 -0
  158. package/dist/series/financial/LineBreakChart.d.ts +23 -0
  159. package/dist/series/financial/PointAndFigureChart.d.ts +24 -0
  160. package/dist/series/financial/RenkoChart.d.ts +22 -0
  161. package/dist/series/financial/VBPChart.d.ts +18 -0
  162. package/dist/series/financial/VolumeChart.d.ts +15 -0
  163. package/dist/series/flow/DependencyWheelChart.d.ts +23 -0
  164. package/dist/series/flow/NetworkGraphChart.d.ts +18 -0
  165. package/dist/series/flow/SankeyChart.d.ts +24 -0
  166. package/dist/series/gauge/GaugeChart.d.ts +40 -0
  167. package/dist/series/heatmap/HeatmapChart.d.ts +18 -0
  168. package/dist/series/hierarchical/SunburstChart.d.ts +44 -0
  169. package/dist/series/hierarchical/TreegraphChart.d.ts +19 -0
  170. package/dist/series/hierarchical/TreemapChart.d.ts +20 -0
  171. package/dist/series/hierarchical/WordcloudChart.d.ts +19 -0
  172. package/dist/series/index.d.ts +45 -0
  173. package/dist/series/map/FlowmapChart.d.ts +33 -0
  174. package/dist/series/map/MapChart.d.ts +53 -0
  175. package/dist/series/map/MapPointChart.d.ts +26 -0
  176. package/dist/series/map/mapProjection.d.ts +46 -0
  177. package/dist/series/pie/PieChart.d.ts +53 -0
  178. package/dist/series/polar/PolarChart.d.ts +18 -0
  179. package/dist/series/race/BarRaceChart.d.ts +44 -0
  180. package/dist/series/timeline/TimelineChart.d.ts +23 -0
  181. package/dist/series/venn/VennChart.d.ts +28 -0
  182. package/dist/stock/DataGrouping.d.ts +21 -0
  183. package/dist/stock/Navigator.d.ts +25 -0
  184. package/dist/stock/RangeSelector.d.ts +9 -0
  185. package/dist/stock/StockController.d.ts +47 -0
  186. package/dist/stockcharts.d.ts +8 -0
  187. package/dist/streaming/StreamAdapter.d.ts +36 -0
  188. package/dist/types/datatable-options.d.ts +633 -0
  189. package/dist/types/options.d.ts +1333 -0
  190. package/dist/utils/CircularBuffer.d.ts +24 -0
  191. package/dist/utils/chartText.d.ts +18 -0
  192. package/dist/utils/color.d.ts +23 -0
  193. package/dist/utils/decimation.d.ts +19 -0
  194. package/dist/utils/deepMerge.d.ts +5 -0
  195. package/dist/utils/dom.d.ts +10 -0
  196. package/dist/utils/format.d.ts +42 -0
  197. package/dist/utils/index.d.ts +7 -0
  198. package/dist/utils/math.d.ts +6 -0
  199. package/dist/utils/throttle.d.ts +2 -0
  200. package/package.json +95 -0
package/README.md ADDED
@@ -0,0 +1,1100 @@
1
+ # KatuCharts
2
+
3
+ D3.js charting library with a declarative configuration interface.
4
+
5
+ ![version](https://img.shields.io/badge/version-0.2.1-blue) ![license](https://img.shields.io/badge/license-KatuCharts_EULA-orange)
6
+
7
+ ---
8
+
9
+ ## Table of Contents
10
+
11
+ - [Install](#install)
12
+ - [Quick Start](#quick-start)
13
+ - [Chart Types](#chart-types)
14
+ - [KatuCharts API](#katucharts-api)
15
+ - [Chart Instance API](#chart-instance-api)
16
+ - [Configuration Reference](#configuration-reference)
17
+ - [chart](#chart-options)
18
+ - [title / subtitle](#title--subtitle)
19
+ - [xAxis / yAxis](#xaxis--yaxis)
20
+ - [series](#series-options)
21
+ - [tooltip](#tooltip)
22
+ - [legend](#legend)
23
+ - [exporting](#exporting)
24
+ - [accessibility](#accessibility)
25
+ - [drilldown](#drilldown)
26
+ - [responsive](#responsive)
27
+ - [Modules](#modules)
28
+ - [Finance](#finance-module)
29
+ - [Bio](#bio-module)
30
+ - [DataTable](#datatable-module)
31
+ - [React](#react-wrapper)
32
+ - [Streaming & Real-time](#streaming--real-time)
33
+ - [Events](#events)
34
+ - [Export](#export)
35
+ - [Custom Modules](#custom-modules)
36
+ - [License](#license)
37
+
38
+ ---
39
+
40
+ ## Install
41
+
42
+ ```bash
43
+ npm install katucharts
44
+ yarn add katucharts
45
+ pnpm add katucharts
46
+ bun add katucharts
47
+ ```
48
+
49
+ Optional peer dependencies:
50
+
51
+ ```bash
52
+ # required only for PDF export
53
+ npm install jspdf
54
+ pnpm add jspdf
55
+
56
+ # required only for React wrapper
57
+ npm install react react-dom
58
+ pnpm add react react-dom
59
+ ```
60
+
61
+ ---
62
+
63
+ ## Quick Start
64
+
65
+ **ESM**
66
+
67
+ ```js
68
+ import KatuCharts from 'katucharts';
69
+
70
+ KatuCharts.chart('container', {
71
+ title: { text: 'Monthly Sales' },
72
+ xAxis: { categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May'] },
73
+ series: [{
74
+ type: 'column',
75
+ name: 'Revenue',
76
+ data: [120, 200, 150, 80, 270]
77
+ }]
78
+ });
79
+ ```
80
+
81
+ **UMD (CDN)**
82
+
83
+ ```html
84
+ <script src="https://unpkg.com/katucharts/dist/katucharts.umd.js"></script>
85
+ <script>
86
+ KatuCharts.chart('container', { series: [{ type: 'line', data: [1, 2, 3] }] });
87
+ </script>
88
+ ```
89
+
90
+ **With modules**
91
+
92
+ ```js
93
+ import KatuCharts from 'katucharts';
94
+ import { BioModule } from 'katucharts/bio';
95
+ import { FinanceModule } from 'katucharts/finance';
96
+
97
+ KatuCharts.use(BioModule);
98
+ KatuCharts.use(FinanceModule);
99
+ ```
100
+
101
+ ---
102
+
103
+ ## Chart Types
104
+
105
+ ### Core — Cartesian
106
+
107
+ | Type | Description |
108
+ |------|-------------|
109
+ | `line` | Multi-point line series with optional markers |
110
+ | `spline` | Smooth interpolated line |
111
+ | `area` | Filled line area |
112
+ | `areaspline` | Smooth filled area |
113
+ | `column` | Vertical bars (stacked, grouped, or range) |
114
+ | `bar` | Horizontal bars (inverted column) |
115
+ | `scatter` | Point cloud |
116
+ | `bubble` | Scatter with Z-value as radius |
117
+ | `heatmap` | 2D grid with color scale |
118
+ | `boxplot` | Box-and-whisker distribution |
119
+ | `waterfall` | Cumulative change visualization |
120
+
121
+ ### Core — Non-Cartesian
122
+
123
+ | Type | Description |
124
+ |------|-------------|
125
+ | `pie` | Pie chart with slicing and drilldown |
126
+ | `donut` | Alias for pie with inner radius |
127
+ | `gauge` | Speedometer-style gauge |
128
+ | `solidgauge` | Solid radial gauge |
129
+ | `polar` | Polar coordinate plot |
130
+ | `radar` | Alias for polar |
131
+
132
+ ### Core — Hierarchical
133
+
134
+ | Type | Description |
135
+ |------|-------------|
136
+ | `treemap` | Squarified treemap with levels |
137
+ | `sunburst` | Radial treemap with drilldown |
138
+ | `venn` | 2- or 3-way Venn diagram |
139
+ | `funnel` | Funnel/conversion visualization |
140
+ | `pyramid` | Pyramid chart |
141
+
142
+ ### Core — Specialized
143
+
144
+ | Type | Description |
145
+ |------|-------------|
146
+ | `timeline` | Event timeline |
147
+ | `gantt` | Project Gantt chart |
148
+ | `map` | Geographic map with regions |
149
+ | `barchartrace` | Animated bar chart race |
150
+
151
+ ### Flow & Network
152
+
153
+ | Type | Description |
154
+ |------|-------------|
155
+ | `sankey` | Flow/alluvial diagram (requires `d3-sankey`) |
156
+ | `networkgraph` | Force-directed network graph |
157
+ | `dependencywheel` | Circular dependency diagram |
158
+
159
+ ### Financial (`katucharts/finance`)
160
+
161
+ | Type | Description |
162
+ |------|-------------|
163
+ | `candlestick` | OHLC candlestick |
164
+ | `ohlc` | Open-High-Low-Close bars |
165
+ | `heikinashi` | Heikin-Ashi candlestick |
166
+ | `hollowcandlestick` | Hollow candlestick |
167
+ | `volume` | Trading volume bars |
168
+ | `arearange` | Area between range boundaries |
169
+ | `baseline` | Profit/loss from a baseline value |
170
+ | `flags` | Event markers on a series |
171
+ | `renko` | Fixed-move block chart |
172
+ | `kagi` | Price reversal chart |
173
+ | `pointandfigure` | Point & figure chart |
174
+ | `linebreak` | Line break reversal chart |
175
+
176
+ ### Bioinformatics (`katucharts/bio`)
177
+
178
+ | Type | Description |
179
+ |------|-------------|
180
+ | `volcano` | Volcano plot (p-value vs fold-change) |
181
+ | `manhattan` | Manhattan plot (GWAS) |
182
+ | `violin` | Violin plot (distribution) |
183
+ | `kaplanmeier` | Kaplan-Meier survival curve |
184
+ | `forestplot` | Forest plot (meta-analysis) |
185
+ | `sequencelogo` | Sequence logo |
186
+ | `clusteredheatmap` | Heatmap with dendrograms |
187
+ | `phylotree` | Phylogenetic tree |
188
+ | `circos` | Circos circular layout |
189
+ | `circosChord` | Circos chord diagram |
190
+ | `circosHeatmap` | Circos heatmap tracks |
191
+ | `circosComparative` | Circos comparative layout |
192
+ | `circosSpiral` | Circos spiral layout |
193
+
194
+ ---
195
+
196
+ ## KatuCharts API
197
+
198
+ All methods are on the `KatuCharts` static object.
199
+
200
+ ### `KatuCharts.chart(container, options)`
201
+
202
+ Creates and returns a Chart instance.
203
+
204
+ | Parameter | Type | Description |
205
+ |-----------|------|-------------|
206
+ | `container` | `string \| HTMLElement` | DOM element ID or element reference |
207
+ | `options` | `KatuChartsOptions` | Chart configuration object |
208
+
209
+ **Returns:** `Chart`
210
+
211
+ ```js
212
+ const chart = KatuCharts.chart('my-chart', { series: [{ data: [1, 2, 3] }] });
213
+ ```
214
+
215
+ ### `KatuCharts.setOptions(options)`
216
+
217
+ Sets global defaults applied to every subsequent chart.
218
+
219
+ ```js
220
+ KatuCharts.setOptions({
221
+ chart: { backgroundColor: '#1a1a2e' },
222
+ legend: { enabled: false }
223
+ });
224
+ ```
225
+
226
+ ### `KatuCharts.getOptions()`
227
+
228
+ Returns the current global options object.
229
+
230
+ ### `KatuCharts.use(module)`
231
+
232
+ Registers a plugin module.
233
+
234
+ ```js
235
+ import { FinanceModule } from 'katucharts/finance';
236
+ KatuCharts.use(FinanceModule);
237
+ ```
238
+
239
+ ### `KatuCharts.dateFormat(value, format)`
240
+
241
+ Formats a date using D3 time format strings.
242
+
243
+ ```js
244
+ KatuCharts.dateFormat(new Date(), '%Y-%m-%d');
245
+ ```
246
+
247
+ ### `KatuCharts.numberFormat(value, decimals?)`
248
+
249
+ Formats a number with thousand separators and optional decimal places.
250
+
251
+ ```js
252
+ KatuCharts.numberFormat(1234567.89, 2); // "1,234,567.89"
253
+ ```
254
+
255
+ ### `KatuCharts.templateFormat(template, context)`
256
+
257
+ Substitutes `{key}` placeholders in a template string.
258
+
259
+ ```js
260
+ KatuCharts.templateFormat('{name}: {value}', { name: 'Revenue', value: 500 });
261
+ ```
262
+
263
+ ### `KatuCharts.stripHtmlTags(html)`
264
+
265
+ Removes HTML tags from a string.
266
+
267
+ ### `KatuCharts.color(input)`
268
+
269
+ Parses a color string (hex, rgb, named) and returns `{ r, g, b, a? }`.
270
+
271
+ ### `KatuCharts.getPalette(name)`
272
+
273
+ Returns a color array for a named palette. Available palettes are listed in `KatuCharts.palettes`.
274
+
275
+ ### `KatuCharts.setTheme(name)`
276
+
277
+ Applies a named theme from `KatuCharts.THEMES` to all subsequent charts.
278
+
279
+ ### `KatuCharts.ChartRegistry`
280
+
281
+ Low-level registry for series type constructors.
282
+
283
+ | Method | Description |
284
+ |--------|-------------|
285
+ | `registerType(name, constructor)` | Registers a custom series type |
286
+ | `getType(name)` | Returns the constructor for a type |
287
+ | `hasType(name)` | Returns `true` if the type is registered |
288
+ | `getRegisteredTypes()` | Returns all registered type names |
289
+
290
+ ---
291
+
292
+ ## Chart Instance API
293
+
294
+ Methods available on the object returned by `KatuCharts.chart()`.
295
+
296
+ ### `chart.update(options, redraw?)`
297
+
298
+ Updates configuration and optionally redraws. Pass `redraw: false` to batch multiple updates.
299
+
300
+ ```js
301
+ chart.update({ title: { text: 'New Title' } });
302
+ ```
303
+
304
+ ### `chart.destroy()`
305
+
306
+ Removes the chart from the DOM and releases all resources.
307
+
308
+ ### `chart.redraw(animate?)`
309
+
310
+ Forces a full redraw. Pass `false` to skip animation.
311
+
312
+ ### `chart.reflow()`
313
+
314
+ Recalculates layout and responsive breakpoints. Call after the container is resized.
315
+
316
+ ### `chart.getContainer()`
317
+
318
+ Returns the container `HTMLElement`.
319
+
320
+ ### `chart.getSVG()`
321
+
322
+ Returns the root `SVGSVGElement`, or `null` if not yet rendered.
323
+
324
+ ### `chart.getSeries(index?)`
325
+
326
+ Returns a single `BaseSeries` by index, or all series if index is omitted.
327
+
328
+ ### `chart.getAxis(isX?, index?)`
329
+
330
+ Returns an axis instance. Pass `true` for X-axes, `false` for Y-axes. Omit `index` to get all.
331
+
332
+ ### `chart.showLoading(text?)`
333
+
334
+ Shows a loading overlay with optional text.
335
+
336
+ ### `chart.hideLoading()`
337
+
338
+ Hides the loading overlay.
339
+
340
+ ### `chart.print(maxWidth?)`
341
+
342
+ Opens the browser print dialog for the chart.
343
+
344
+ ### `chart.exportChart(exportingOptions?)`
345
+
346
+ Triggers an export. Merges with chart's `exporting` config.
347
+
348
+ ```js
349
+ chart.exportChart({ format: 'image/png', filename: 'my-chart' });
350
+ ```
351
+
352
+ ### `chart.fireEvent(eventName, eventObject?)`
353
+
354
+ Manually fires a chart event.
355
+
356
+ ---
357
+
358
+ ## Configuration Reference
359
+
360
+ ### chart options
361
+
362
+ | Option | Type | Default | Description |
363
+ |--------|------|---------|-------------|
364
+ | `type` | `string` | `'line'` | Default series type |
365
+ | `width` | `number \| null` | `null` | Width in pixels; `null` uses container width |
366
+ | `height` | `number \| string \| null` | `null` | Height in pixels, `'50%'`, or `null` |
367
+ | `backgroundColor` | `string` | `'#ffffff'` | Outer background color |
368
+ | `borderColor` | `string` | `'#335cad'` | Chart border color |
369
+ | `borderWidth` | `number` | `0` | Border width in pixels |
370
+ | `borderRadius` | `number` | `0` | Rounded corner radius |
371
+ | `margin` | `number \| number[]` | auto | `[top, right, bottom, left]` in pixels |
372
+ | `marginTop` | `number` | auto | |
373
+ | `marginRight` | `number` | auto | |
374
+ | `marginBottom` | `number` | auto | |
375
+ | `marginLeft` | `number` | auto | |
376
+ | `spacing` | `number[]` | `[10,10,15,10]` | Inner spacing `[top,right,bottom,left]` |
377
+ | `plotBackgroundColor` | `string` | `null` | Plot area background |
378
+ | `plotBorderWidth` | `number` | `0` | Plot area border width |
379
+ | `plotShadow` | `boolean` | `false` | Drop shadow on plot area |
380
+ | `inverted` | `boolean` | `false` | Swaps X and Y axes |
381
+ | `polar` | `boolean` | `false` | Polar coordinate system |
382
+ | `reflow` | `boolean` | `true` | Auto-reflow on container resize |
383
+ | `animation` | `boolean \| object` | `true` | `{ duration, easing }` |
384
+ | `zoomType` | `'x' \| 'y' \| 'xy'` | — | Enable drag-to-zoom |
385
+ | `panning` | `boolean \| object` | `false` | Enable panning; `{ enabled, type }` |
386
+ | `panKey` | `string` | `'shift'` | Modifier key required to pan |
387
+ | `palette` | `string` | `'default'` | Color palette name |
388
+ | `colorCount` | `number` | `10` | Number of palette colors to cycle |
389
+ | `styledMode` | `boolean` | `false` | Use external CSS instead of inline styles |
390
+ | `numberFormatter` | `function` | — | Override global number formatting |
391
+ | `events` | `object` | — | Chart-level event callbacks (see [Events](#events)) |
392
+
393
+ ### title / subtitle
394
+
395
+ ```js
396
+ {
397
+ title: {
398
+ text: 'Chart Title',
399
+ align: 'center', // 'left' | 'center' | 'right'
400
+ verticalAlign: 'top', // 'top' | 'middle' | 'bottom'
401
+ x: 0,
402
+ y: 15,
403
+ floating: false,
404
+ style: { fontSize: '18px', color: '#333333' }
405
+ },
406
+ subtitle: {
407
+ text: 'Optional subtitle',
408
+ align: 'center',
409
+ style: { color: '#666666' }
410
+ }
411
+ }
412
+ ```
413
+
414
+ ### xAxis / yAxis
415
+
416
+ Both accept a single object or an array for multiple axes.
417
+
418
+ | Option | Type | Default | Description |
419
+ |--------|------|---------|-------------|
420
+ | `type` | `'linear' \| 'logarithmic' \| 'datetime' \| 'category'` | `'linear'` | Scale type |
421
+ | `title` | `object` | — | `{ text, style }` |
422
+ | `labels` | `object` | — | `{ format, formatter, rotation, style }` |
423
+ | `min` | `number \| null` | auto | Axis minimum |
424
+ | `max` | `number \| null` | auto | Axis maximum |
425
+ | `softMin` | `number` | — | Soft minimum (data can exceed it) |
426
+ | `softMax` | `number` | — | Soft maximum |
427
+ | `tickInterval` | `number` | auto | Interval between ticks |
428
+ | `tickAmount` | `number` | — | Exact number of ticks |
429
+ | `tickLength` | `number` | `10` | Tick mark length |
430
+ | `tickWidth` | `number` | `1` | Tick mark width |
431
+ | `tickPosition` | `'inside' \| 'outside'` | `'outside'` | |
432
+ | `gridLineWidth` | `number` | `1` | Grid line width |
433
+ | `gridLineColor` | `string` | `'#e6e6e6'` | |
434
+ | `gridLineDashStyle` | `string` | `'Solid'` | |
435
+ | `lineWidth` | `number` | `1` | Axis line width |
436
+ | `opposite` | `boolean` | `false` | Place on opposite side (right/top) |
437
+ | `reversed` | `boolean` | `false` | Reverse scale direction |
438
+ | `visible` | `boolean` | `true` | |
439
+ | `categories` | `string[]` | — | Category axis values |
440
+ | `crosshair` | `boolean \| object` | `false` | `{ width, color, dashStyle, snap }` |
441
+ | `plotBands` | `PlotBand[]` | — | Shaded regions: `{ from, to, color, label }` |
442
+ | `plotLines` | `PlotLine[]` | — | Reference lines: `{ value, width, color, label }` |
443
+ | `startOnTick` | `boolean` | `true` | |
444
+ | `endOnTick` | `boolean` | `true` | |
445
+ | `alternateGridColor` | `string` | — | Zebra-stripe alternate grid color |
446
+ | `dateTimeLabelFormats` | `object` | — | Format strings per time unit |
447
+ | `events` | `object` | — | `{ afterSetExtremes, setExtremes }` |
448
+
449
+ ```js
450
+ yAxis: {
451
+ type: 'logarithmic',
452
+ title: { text: 'Concentration (μM)' },
453
+ plotLines: [{ value: 0, width: 1, color: '#808080' }],
454
+ plotBands: [{ from: 0, to: 10, color: 'rgba(68,170,213,0.1)', label: { text: 'Normal' } }]
455
+ }
456
+ ```
457
+
458
+ ### series options
459
+
460
+ Each object in the `series` array accepts these options:
461
+
462
+ | Option | Type | Default | Description |
463
+ |--------|------|---------|-------------|
464
+ | `type` | `string` | chart default | Overrides chart-level type |
465
+ | `name` | `string` | — | Displayed in legend and tooltip |
466
+ | `data` | `array` | **required** | See data formats below |
467
+ | `color` | `string` | palette | Series color |
468
+ | `colorIndex` | `number` | — | Explicit palette index |
469
+ | `visible` | `boolean` | `true` | |
470
+ | `showInLegend` | `boolean` | `true` | |
471
+ | `opacity` | `number` | `1` | |
472
+ | `lineWidth` | `number` | `2` | Line thickness |
473
+ | `dashStyle` | `string` | `'Solid'` | `'Dash'`, `'Dot'`, `'DashDot'`, etc. |
474
+ | `fillColor` | `string` | — | Area fill color |
475
+ | `fillOpacity` | `number` | `0.75` | Area fill opacity |
476
+ | `borderWidth` | `number` | type-dependent | |
477
+ | `borderColor` | `string` | — | |
478
+ | `borderRadius` | `number` | `0` | Column corner radius |
479
+ | `marker` | `object` | — | `{ enabled, symbol, radius, fillColor, lineWidth, lineColor }` |
480
+ | `dataLabels` | `object` | — | `{ enabled, format, formatter, style, position }` |
481
+ | `stacking` | `'normal' \| 'percent'` | — | Stack series |
482
+ | `stack` | `string \| number` | — | Stack group identifier |
483
+ | `negativeColor` | `string` | — | Color for values below threshold |
484
+ | `threshold` | `number \| null` | `0` | |
485
+ | `zones` | `Zone[]` | — | `[{ value, color, fillColor, dashStyle }]` |
486
+ | `step` | `'left' \| 'center' \| 'right' \| false` | `false` | Step line type |
487
+ | `connectNulls` | `boolean` | `false` | |
488
+ | `pointStart` | `number` | — | X value of the first point |
489
+ | `pointInterval` | `number` | `1` | Interval between auto-generated X values |
490
+ | `xAxis` | `number \| string` | `0` | Axis index or id |
491
+ | `yAxis` | `number \| string` | `0` | |
492
+ | `enableMouseTracking` | `boolean` | `true` | |
493
+ | `allowPointSelect` | `boolean` | `false` | |
494
+ | `drilldown` | `string` | — | Drilldown series ID |
495
+ | `events` | `object` | — | `{ click, mouseOver, mouseOut, legendItemClick, show, hide, afterAnimate }` |
496
+
497
+ **Data formats:**
498
+
499
+ ```js
500
+ // Simple array of values (auto X)
501
+ data: [10, 20, 30]
502
+
503
+ // [x, y] pairs
504
+ data: [[0, 10], [1, 20], [2, 30]]
505
+
506
+ // [x, y, z] for bubble charts
507
+ data: [[0, 10, 5], [1, 20, 8]]
508
+
509
+ // [category, value]
510
+ data: [['Jan', 120], ['Feb', 200]]
511
+
512
+ // Point objects
513
+ data: [
514
+ { x: 0, y: 10, name: 'Alpha', color: '#ff0000', custom: { extra: 'data' } },
515
+ { x: 1, y: null }, // null creates a gap
516
+ { x: 2, y: 30, sliced: true, selected: true }
517
+ ]
518
+ ```
519
+
520
+ ### map & globe
521
+
522
+ The `map` series renders a choropleth from geographic topology you supply via
523
+ `mapData`. It accepts either a **GeoJSON** `FeatureCollection` (or a bare feature
524
+ array) **or a TopoJSON** topology — TopoJSON is converted automatically, so the
525
+ same option works for both formats. The projection lives on `mapView`, the
526
+ `colorAxis` and `mapNavigation` at the chart level. Set the projection to
527
+ `Orthographic` to turn the same data into an interactive 3D globe.
528
+
529
+ ```js
530
+ KatuCharts.chart('container', {
531
+ chart: { type: 'map', map: worldGeoJsonOrTopoJson }, // GeoJSON or TopoJSON
532
+ mapView: { projection: { name: 'EqualEarth' } }, // 'Orthographic' for a globe
533
+ colorAxis: { min: 0, max: 100, minColor: '#e6f2ff', maxColor: '#08306b' },
534
+ mapNavigation: { enabled: true },
535
+ series: [{
536
+ name: 'Population',
537
+ joinBy: 'ADM0_A3', // feature property ↔ data key (or ['featureKey','dataKey'])
538
+ data: [
539
+ { ADM0_A3: 'BRA', value: 80 },
540
+ { ADM0_A3: 'USA', value: 65 },
541
+ ],
542
+ }],
543
+ });
544
+ ```
545
+
546
+ > `colorAxis`, `mapView.projection`, `mapNavigation` and `chart.map` may also be
547
+ > placed directly on the series (`series[].colorAxis`, `series[].projection`,
548
+ > `series[].mapNavigation`, `series[].mapData`) — series-level options win.
549
+
550
+ **Chart-level options**
551
+
552
+ | Option | Type | Default | Description |
553
+ |--------|------|---------|-------------|
554
+ | `chart.map` | `GeoJSON` \| `TopoJSON` | — | Topology to render (or set `series[].mapData`). |
555
+ | `mapView.projection` | `object` | `{ name: 'naturalEarth' }` | `{ name, rotation, center, scale, parallels }`. |
556
+ | `colorAxis` | `object` | `{}` | `{ min, max, minColor, maxColor }`, `{ stops: [[0,'#fff'],[1,'#000']] }`, or `{ colorScheme }` (`blues`, `viridis`, `plasma`, `inferno`, `ylOrRd`, `rdYlGn`, …). `enabled: false` hides the legend. |
557
+ | `mapNavigation` | `object` | `{ enabled: true }` | Pan/zoom: `enableMouseWheelZoom`, `enableDoubleClickZoom`, `enableDrag`, `enableButtons`, `maxZoom`. Ignored in globe mode. |
558
+
559
+ **Projection names** — PascalCase `Orthographic`, `WebMercator`, `EqualEarth`,
560
+ `LambertConformalConic`, `Miller`; or the d3 set: `naturalEarth`, `mercator`,
561
+ `equirectangular`, `albers`, `albersUsa`, `stereographic`, `conicEqualArea`,
562
+ `conicEquidistant`, `transverseMercator`, `azimuthalEqualArea`,
563
+ `azimuthalEquidistant`, `gnomonic`.
564
+
565
+ **Series options**
566
+
567
+ | Option | Type | Default | Description |
568
+ |--------|------|---------|-------------|
569
+ | `mapData` | `GeoJSON` \| `TopoJSON` \| `Feature[]` | — | Topology (overrides `chart.map`). |
570
+ | `mapDataObject` | `string` | auto | TopoJSON only — which `objects` key to use (defaults to `countries`, else the first). |
571
+ | `joinBy` | `string` \| `[string, string]` | `['hc-key','code']` | Links data rows to features. Single string uses the same key on both sides. |
572
+ | `nullColor` | `string` | `'#f0f0f0'` | Fill for features without a matching data row. |
573
+ | `allAreas` | `boolean` | `true` | When `false`, only features that have data are drawn. |
574
+ | `borderColor` / `borderWidth` | `string` / `number` | `'#cccccc'` / `0.5` | Feature outlines. |
575
+ | `dataLabels` | `object` | `{ enabled: false }` | `{ enabled, format, formatter, style }` — labels at feature centroids. |
576
+ | `options3d` | `object` | `{ enabled: false }` | Globe tuning: `{ enabled, oceanColor, atmosphereColor, graticule, graticuleColor, autoRotate, rotateSpeed, shadow }`. Drag rotates, wheel zooms. |
577
+
578
+ **Where to get topology data.** KatuCharts ships no map data — supply your own.
579
+ [Natural Earth](https://www.naturalearthdata.com/) is public domain (CC0): the
580
+ `ne_110m_admin_0_countries` GeoJSON works directly, and the compact
581
+ [`world-atlas`](https://github.com/topojson/world-atlas) TopoJSON
582
+ (`countries-110m.json`) can be passed straight into `mapData`.
583
+
584
+ > **Join-key tip:** Natural Earth's `ISO_A2`/`ISO_A3` are `-99` for a handful of
585
+ > entities (France, Norway, …). Use **`ADM0_A3`** as your `joinBy` key to avoid
586
+ > gaps. See `dev/map.html` and `dev/globe.html` for runnable examples.
587
+
588
+ ### tooltip
589
+
590
+ | Option | Type | Default | Description |
591
+ |--------|------|---------|-------------|
592
+ | `enabled` | `boolean` | `true` | |
593
+ | `shared` | `boolean` | `false` | Show all series at the hovered X |
594
+ | `split` | `boolean` | `false` | Separate callout per series |
595
+ | `useHTML` | `boolean` | `false` | Render tooltip content as HTML |
596
+ | `followPointer` | `boolean` | `false` | Move with cursor |
597
+ | `format` | `string` | — | Template using `{point.x}`, `{series.name}`, etc. |
598
+ | `headerFormat` | `string` | — | Header template |
599
+ | `pointFormat` | `string` | — | Per-point template |
600
+ | `formatter` | `function` | — | `function() { return '...'; }` — `this` is the context |
601
+ | `positioner` | `function` | — | `(width, height, point) => ({ x, y })` |
602
+ | `backgroundColor` | `string` | `'rgba(247,247,247,0.85)'` | |
603
+ | `borderColor` | `string` | auto | |
604
+ | `borderWidth` | `number` | `1` | |
605
+ | `borderRadius` | `number` | `3` | |
606
+ | `padding` | `number` | `8` | |
607
+ | `shadow` | `boolean` | `true` | |
608
+ | `hideDelay` | `number` | `500` | Milliseconds before hiding |
609
+ | `distance` | `number` | `16` | Distance from point in pixels |
610
+ | `outside` | `boolean` | `false` | Allow tooltip outside chart bounds |
611
+ | `stickOnContact` | `boolean` | `false` | Prevent hiding when mouse enters tooltip |
612
+
613
+ ```js
614
+ tooltip: {
615
+ shared: true,
616
+ formatter() {
617
+ return this.points.map(p => `<b>${p.series.name}</b>: ${p.y}`).join('<br>');
618
+ },
619
+ useHTML: true
620
+ }
621
+ ```
622
+
623
+ ### legend
624
+
625
+ | Option | Type | Default | Description |
626
+ |--------|------|---------|-------------|
627
+ | `enabled` | `boolean` | `true` | |
628
+ | `layout` | `'horizontal' \| 'vertical' \| 'proximate'` | `'horizontal'` | |
629
+ | `align` | `'left' \| 'center' \| 'right'` | `'center'` | |
630
+ | `verticalAlign` | `'top' \| 'middle' \| 'bottom'` | `'bottom'` | |
631
+ | `floating` | `boolean` | `false` | Overlap chart area |
632
+ | `x` | `number` | `0` | Horizontal offset |
633
+ | `y` | `number` | `0` | Vertical offset |
634
+ | `maxHeight` | `number` | — | Max height before scrolling |
635
+ | `itemDistance` | `number` | `20` | Space between items |
636
+ | `symbolWidth` | `number` | `16` | Legend symbol width |
637
+ | `symbolHeight` | `number` | `12` | Legend symbol height |
638
+ | `squareSymbol` | `boolean` | `true` | |
639
+ | `backgroundColor` | `string` | — | |
640
+ | `borderWidth` | `number` | `0` | |
641
+ | `borderRadius` | `number` | `0` | |
642
+ | `reversed` | `boolean` | `false` | Reverse item order |
643
+ | `rtl` | `boolean` | `false` | Right-to-left |
644
+ | `labelFormatter` | `function` | — | `function() { return this.name; }` |
645
+ | `labelFormat` | `string` | `'{name}'` | Template for item labels |
646
+
647
+ ### exporting
648
+
649
+ | Option | Type | Default | Description |
650
+ |--------|------|---------|-------------|
651
+ | `enabled` | `boolean` | `true` | Show export button |
652
+ | `format` | `string` | `'image/png'` | Default export format |
653
+ | `scale` | `number` | `2` | Resolution multiplier |
654
+ | `quality` | `number` | `0.95` | JPEG quality (0–1) |
655
+ | `filename` | `string` | `'chart'` | Downloaded file name |
656
+ | `sourceWidth` | `number` | — | Export width override |
657
+ | `sourceHeight` | `number` | — | Export height override |
658
+ | `chartOptions` | `object` | — | Overrides applied only during export |
659
+ | `csv.dateFormat` | `string` | — | Date format in CSV |
660
+ | `csv.decimalPoint` | `string` | `'.'` | |
661
+ | `csv.itemDelimiter` | `string` | `','` | |
662
+ | `csv.lineDelimiter` | `string` | `'\n'` | |
663
+ | `buttons.contextButton.menuItems` | `string[]` | all | Items in export menu |
664
+
665
+ ```js
666
+ exporting: {
667
+ filename: 'my-report',
668
+ scale: 3,
669
+ chartOptions: { title: { style: { color: '#000' } } }
670
+ }
671
+ ```
672
+
673
+ ### accessibility
674
+
675
+ | Option | Type | Default | Description |
676
+ |--------|------|---------|-------------|
677
+ | `enabled` | `boolean` | `true` | ARIA roles and descriptions |
678
+ | `description` | `string` | auto | Override auto-generated description |
679
+ | `landmarkVerbosity` | `'all' \| 'minimal' \| 'none'` | `'all'` | |
680
+ | `keyboardNavigation.enabled` | `boolean` | `true` | |
681
+ | `announceNewData.enabled` | `boolean` | `false` | Announce streaming updates |
682
+ | `announceNewData.minAnnounceInterval` | `number` | `5000` | Milliseconds between announcements |
683
+
684
+ ### drilldown
685
+
686
+ ```js
687
+ drilldown: {
688
+ series: [
689
+ { id: 'Q1', type: 'column', name: 'Q1 Detail', data: [30, 40, 50] }
690
+ ],
691
+ breadcrumbs: {
692
+ enabled: true,
693
+ position: { align: 'right', verticalAlign: 'top' }
694
+ },
695
+ animation: { duration: 300 }
696
+ }
697
+ ```
698
+
699
+ Each top-level series point references a drilldown series by `drilldown: 'id'`.
700
+
701
+ ### responsive
702
+
703
+ ```js
704
+ chart: {
705
+ responsive: {
706
+ rules: [{
707
+ condition: { maxWidth: 600 },
708
+ chartOptions: {
709
+ legend: { enabled: false },
710
+ yAxis: { title: { text: '' } }
711
+ }
712
+ }]
713
+ }
714
+ }
715
+ ```
716
+
717
+ ---
718
+
719
+ ## Modules
720
+
721
+ ### Finance Module
722
+
723
+ ```js
724
+ import KatuCharts from 'katucharts';
725
+ import { FinanceModule } from 'katucharts/finance';
726
+
727
+ KatuCharts.use(FinanceModule);
728
+ ```
729
+
730
+ Enables all [financial chart types](#financial-katucharts-finance) plus technical indicators.
731
+
732
+ **Technical Indicators**
733
+
734
+ Indicators are computed from OHLCV data and rendered as overlay series.
735
+
736
+ | Indicator | Constructor | Parameters |
737
+ |-----------|------------|------------|
738
+ | SMA | `SMA(data, period)` | period |
739
+ | EMA | `EMA(data, period, multiplier?)` | period, optional multiplier |
740
+ | WMA | `WMA(data, period)` | period |
741
+ | RSI | `RSI(data, period)` | period |
742
+ | MACD | `MACD(data, fast, slow, signal)` | fast/slow/signal periods |
743
+ | Stochastic | `Stochastic(data, kPeriod, smoothK, smoothD)` | |
744
+ | Bollinger Bands | `BollingerBands(data, period, stdDevs)` | |
745
+ | ATR | `ATR(data, period)` | |
746
+ | VWAP | `VWAP(data, volumeKey)` | key for volume column |
747
+ | OBV | `OBV(data)` | |
748
+ | Ichimoku | `IchimokuCloud(data, tenkan, kijun, ...)` | |
749
+
750
+ All indicators expose `.calculate()` and `.getResult()` and return data in `[x, y]` series format.
751
+
752
+ ```js
753
+ import { FinanceModule, EMA } from 'katucharts/finance';
754
+
755
+ KatuCharts.use(FinanceModule);
756
+
757
+ const ema = new EMA(ohlcData, 20);
758
+ ema.calculate();
759
+ const emaData = ema.getResult();
760
+
761
+ KatuCharts.chart('container', {
762
+ series: [
763
+ { type: 'candlestick', name: 'AAPL', data: ohlcData },
764
+ { type: 'line', name: 'EMA 20', data: emaData, lineWidth: 1 }
765
+ ]
766
+ });
767
+ ```
768
+
769
+ ### Bio Module
770
+
771
+ ```js
772
+ import KatuCharts from 'katucharts';
773
+ import { BioModule } from 'katucharts/bio';
774
+
775
+ KatuCharts.use(BioModule);
776
+ ```
777
+
778
+ Enables all [bioinformatics chart types](#bioinformatics-katuchartsbio).
779
+
780
+ ```js
781
+ KatuCharts.chart('container', {
782
+ series: [{
783
+ type: 'volcano',
784
+ name: 'DEG Analysis',
785
+ data: genes.map(g => ({ x: g.log2fc, y: -Math.log10(g.pvalue), name: g.symbol }))
786
+ }]
787
+ });
788
+ ```
789
+
790
+ ### DataTable Module
791
+
792
+ ```js
793
+ import KatuCharts from 'katucharts';
794
+ import { DataTableModule, DataTable } from 'katucharts/datatable';
795
+
796
+ KatuCharts.use(DataTableModule);
797
+ ```
798
+
799
+ **`new DataTable(container, options)`**
800
+
801
+ | Method | Description |
802
+ |--------|-------------|
803
+ | `setData(data, columns?)` | Replace all data |
804
+ | `getData()` | Return current data array |
805
+ | `getSelectedRows()` | Return selected row objects |
806
+ | `selectRows(indices, triggerEvent?)` | Programmatic selection |
807
+ | `deselectRows(indices?, triggerEvent?)` | Deselect rows |
808
+ | `clearSelection()` | Clear all selections |
809
+ | `sort(columnId, direction?)` | Sort by column |
810
+ | `filter(filters)` | Apply `[{ column, value, operator }]` filters |
811
+ | `search(query)` | Global text search |
812
+ | `exportData(format, filename?)` | Download as `'csv'` or `'json'` |
813
+ | `destroy()` | Remove and release resources |
814
+
815
+ **ColumnDefinition**
816
+
817
+ | Option | Type | Description |
818
+ |--------|------|-------------|
819
+ | `id` | `string` | **required** — column identifier |
820
+ | `title` | `string` | Header label |
821
+ | `type` | `'string' \| 'number' \| 'date' \| 'boolean' \| 'custom'` | |
822
+ | `width` | `number \| string` | Column width |
823
+ | `sortable` | `boolean` | |
824
+ | `filterable` | `boolean` | |
825
+ | `formatter` | `(value, row) => string` | Custom cell renderer |
826
+ | `visible` | `boolean` | |
827
+ | `align` | `'left' \| 'center' \| 'right'` | |
828
+ | `pinned` | `'left' \| 'right' \| false` | Freeze column |
829
+ | `cellStyle` | `(value, row) => CSSObject` | Dynamic inline style |
830
+
831
+ **DataTableOptions (key fields)**
832
+
833
+ ```js
834
+ const table = new DataTable('container', {
835
+ data: rows,
836
+ columns: [
837
+ { id: 'name', title: 'Name', type: 'string', sortable: true },
838
+ { id: 'value', title: 'Value', type: 'number', formatter: (v) => v.toFixed(2) }
839
+ ],
840
+ selection: { enabled: true, mode: 'multiple' },
841
+ pagination: { enabled: true, pageSize: 25, pageSizeOptions: [10, 25, 50] },
842
+ sorting: { enabled: true, multiSort: true },
843
+ filtering: { enabled: true, mode: 'both' },
844
+ export: { enabled: true, formats: ['csv', 'json'], filename: 'export' }
845
+ });
846
+ ```
847
+
848
+ ### React Wrapper
849
+
850
+ ```js
851
+ import KatuCharts from 'katucharts';
852
+ import { KatuChartsReact } from 'katucharts/react';
853
+
854
+ function SalesChart() {
855
+ return (
856
+ <KatuChartsReact
857
+ katuCharts={KatuCharts}
858
+ options={{
859
+ chart: { type: 'line' },
860
+ title: { text: 'Monthly Sales' },
861
+ series: [{ name: 'Revenue', data: [120, 200, 150, 80, 270] }]
862
+ }}
863
+ callback={(chart) => {
864
+ console.log('chart ready', chart);
865
+ }}
866
+ containerProps={{ style: { height: '400px' } }}
867
+ />
868
+ );
869
+ }
870
+ ```
871
+
872
+ | Prop | Type | Description |
873
+ |------|------|-------------|
874
+ | `katuCharts` | `KatuChartsStatic` | **required** — the `KatuCharts` import |
875
+ | `options` | `KatuChartsOptions` | **required** — chart configuration |
876
+ | `callback` | `(chart) => void` | Called after chart is initialized |
877
+ | `containerProps` | `HTMLAttributes<HTMLDivElement>` | Props for the wrapper `<div>` |
878
+
879
+ ---
880
+
881
+ ## Streaming & Real-time
882
+
883
+ ### StreamAdapter
884
+
885
+ ```js
886
+ import { StreamAdapter } from 'katucharts';
887
+
888
+ const chart = KatuCharts.chart('container', {
889
+ series: [{ type: 'line', name: 'Live', data: [] }]
890
+ });
891
+ const series = chart.getSeries(0);
892
+ ```
893
+
894
+ **`StreamAdapter.fromWebSocket(ws, series, parseMessage, options?)`**
895
+
896
+ ```js
897
+ const ws = new WebSocket('wss://feed.example.com');
898
+ const sub = StreamAdapter.fromWebSocket(
899
+ ws,
900
+ series,
901
+ (msg) => ({ x: Date.now(), y: JSON.parse(msg.data).value }),
902
+ { shift: true }
903
+ );
904
+ sub.unsubscribe();
905
+ ```
906
+
907
+ **`StreamAdapter.fromEventSource(source, series, eventName, parseMessage, options?)`**
908
+
909
+ ```js
910
+ const source = new EventSource('/stream');
911
+ const sub = StreamAdapter.fromEventSource(
912
+ source,
913
+ series,
914
+ 'price',
915
+ (data) => ({ x: Date.now(), y: parseFloat(data) }),
916
+ { shift: true }
917
+ );
918
+ ```
919
+
920
+ **`StreamAdapter.fromPolling(fetchFn, series, intervalMs, options?)`**
921
+
922
+ ```js
923
+ const sub = StreamAdapter.fromPolling(
924
+ async () => {
925
+ const res = await fetch('/api/latest');
926
+ const json = await res.json();
927
+ return { x: Date.now(), y: json.value };
928
+ },
929
+ series,
930
+ 2000,
931
+ { shift: true }
932
+ );
933
+ ```
934
+
935
+ All three return a `{ unsubscribe() }` handle.
936
+
937
+ ### UpdateScheduler
938
+
939
+ Batch multiple data operations into one redraw.
940
+
941
+ ```js
942
+ import { UpdateScheduler } from 'katucharts';
943
+
944
+ const scheduler = new UpdateScheduler();
945
+
946
+ scheduler.batch(() => {
947
+ scheduler.schedule([
948
+ { type: 'add', seriesIndex: 0, data: { x: 1, y: 10 } },
949
+ { type: 'add', seriesIndex: 1, data: { x: 1, y: 20 } }
950
+ ]);
951
+ });
952
+ ```
953
+
954
+ | Method | Description |
955
+ |--------|-------------|
956
+ | `schedule(updates, redraw?)` | Queue updates |
957
+ | `batch(fn)` | Run `fn` and flush once |
958
+ | `flush()` | Force immediate flush |
959
+ | `clear()` | Discard queued updates |
960
+
961
+ `UpdateEntry.type` values: `'add'`, `'remove'`, `'update'`, `'clear'`, `'replace'`.
962
+
963
+ ### CircularBuffer
964
+
965
+ Fixed-size FIFO buffer for rolling windows.
966
+
967
+ ```js
968
+ import { CircularBuffer } from 'katucharts';
969
+
970
+ const buffer = new CircularBuffer(100);
971
+ buffer.push({ x: Date.now(), y: 42 });
972
+ buffer.toArray(); // last 100 items
973
+ ```
974
+
975
+ ---
976
+
977
+ ## Events
978
+
979
+ ### EventBus API
980
+
981
+ Charts expose an `events` bus accessible after creation. You can also pass callbacks directly in the options object.
982
+
983
+ ```js
984
+ chart.events.on('point:click', (point) => console.log(point));
985
+ chart.events.once('load', () => console.log('ready'));
986
+ chart.events.off('point:click');
987
+ ```
988
+
989
+ | Method | Description |
990
+ |--------|-------------|
991
+ | `on(event, callback)` | Subscribe (persistent) |
992
+ | `once(event, callback)` | Subscribe (fires once, then removed) |
993
+ | `off(event, callback?)` | Unsubscribe; omit callback to remove all listeners for event |
994
+ | `emit(event, ...args)` | Fire event manually |
995
+ | `removeAllListeners()` | Clear every listener |
996
+
997
+ ### Built-in Events
998
+
999
+ | Event | Fired when |
1000
+ |-------|-----------|
1001
+ | `load` | Chart fully initialized |
1002
+ | `redraw` | Chart redrawn |
1003
+ | `render` | Series rendered |
1004
+ | `click` | Chart background clicked |
1005
+ | `selection` | Data selection made |
1006
+ | `addSeries` | Series added dynamically |
1007
+ | `drilldown` | Point drilled into |
1008
+ | `drillup` | Drilled back up |
1009
+ | `beforePrint` | Before print dialog |
1010
+ | `afterPrint` | After print dialog |
1011
+ | `point:mouseover` | Mouse enters a point |
1012
+ | `point:mouseout` | Mouse leaves a point |
1013
+ | `point:click` | Point clicked |
1014
+ | `point:select` | Point selected |
1015
+ | `point:unselect` | Point deselected |
1016
+ | `series:show` | Series shown |
1017
+ | `series:hide` | Series hidden |
1018
+ | `zoom:changed` | Zoom or pan applied |
1019
+
1020
+ Callbacks in the `options` object receive `this` as context:
1021
+
1022
+ ```js
1023
+ chart: {
1024
+ events: {
1025
+ click(event) { console.log('clicked at', event.xAxis[0].value); }
1026
+ }
1027
+ },
1028
+ series: [{
1029
+ events: {
1030
+ legendItemClick() { return false; } // return false to prevent default
1031
+ }
1032
+ }]
1033
+ ```
1034
+
1035
+ ---
1036
+
1037
+ ## Export
1038
+
1039
+ The `ExportModule` functions can be used directly when the built-in export button is insufficient.
1040
+
1041
+ ```js
1042
+ import { ExportModule } from 'katucharts';
1043
+
1044
+ const svg = ExportModule.inlineStyles(chart.getSVG());
1045
+
1046
+ await ExportModule.exportPNG(svg, 'chart', 2);
1047
+ await ExportModule.exportJPEG(svg, 'chart', 2, 0.9);
1048
+ await ExportModule.exportPDF(svg, 'chart', 2); // requires jspdf
1049
+ ExportModule.exportSVG(svg, 'chart');
1050
+ ExportModule.exportCSV(chart.getSeries(), 'data');
1051
+ ExportModule.print(svg, 800);
1052
+ ```
1053
+
1054
+ | Function | Description |
1055
+ |----------|-------------|
1056
+ | `inlineStyles(svgNode)` | Clone SVG and inline computed styles; returns SVG string |
1057
+ | `exportSVG(svgString, filename?)` | Download as `.svg` |
1058
+ | `exportPNG(svgString, filename?, scale?)` | Render to canvas, download `.png` |
1059
+ | `exportJPEG(svgString, filename?, scale?, quality?)` | Download `.jpg` (quality 0–1) |
1060
+ | `exportPDF(svgString, filename?, scale?)` | Download `.pdf` — requires `jspdf` |
1061
+ | `exportCSV(seriesData, filename?, options?)` | Download `.csv` |
1062
+ | `getCSV(seriesData, options?)` | Return CSV as string |
1063
+ | `print(svgString, maxWidth?)` | Open print dialog |
1064
+ | `svgToCanvas(svgString, scale, bgColor?)` | Returns `Promise<HTMLCanvasElement>` |
1065
+
1066
+ ---
1067
+
1068
+ ## Custom Modules
1069
+
1070
+ Any module must implement `{ name: string, init(katucharts): void }`.
1071
+
1072
+ ```js
1073
+ import { BaseSeries } from 'katucharts';
1074
+
1075
+ class RidglineChart extends BaseSeries {
1076
+ render() {
1077
+ // use this.config, this.data, this.chart
1078
+ }
1079
+ }
1080
+
1081
+ const RidgelineModule = {
1082
+ name: 'ridgeline',
1083
+ init(KC) {
1084
+ KC.ChartRegistry.registerType('ridgeline', RidglineChart);
1085
+ }
1086
+ };
1087
+
1088
+ KatuCharts.use(RidgelineModule);
1089
+
1090
+ KatuCharts.chart('container', {
1091
+ series: [{ type: 'ridgeline', data: [...] }]
1092
+ });
1093
+ ```
1094
+
1095
+ ---
1096
+
1097
+ ## License
1098
+
1099
+ Source-available under the [KatuCharts EULA](./LICENSE).
1100
+ Free for personal and commercial use with attribution. Paid license removes attribution requirement.