@chartts/react 0.1.3
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/LICENSE +21 -0
- package/dist/index.cjs +396 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +67 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +117 -0
- package/dist/index.js.map +1 -0
- package/package.json +35 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 chartts
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var core = require('@chartts/core');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
|
|
7
|
+
// src/index.tsx
|
|
8
|
+
function useChart(ref, chartType, data, options) {
|
|
9
|
+
const instance = react.useRef(null);
|
|
10
|
+
react.useEffect(() => {
|
|
11
|
+
if (!ref.current) return;
|
|
12
|
+
instance.current = core.createChart(ref.current, chartType, data, options);
|
|
13
|
+
return () => {
|
|
14
|
+
instance.current?.destroy();
|
|
15
|
+
instance.current = null;
|
|
16
|
+
};
|
|
17
|
+
}, [ref.current]);
|
|
18
|
+
react.useEffect(() => {
|
|
19
|
+
instance.current?.setData(data);
|
|
20
|
+
}, [data]);
|
|
21
|
+
react.useEffect(() => {
|
|
22
|
+
instance.current?.setOptions(options);
|
|
23
|
+
}, [options]);
|
|
24
|
+
return instance;
|
|
25
|
+
}
|
|
26
|
+
function createChartComponent(chartType, displayName) {
|
|
27
|
+
const Component = react.forwardRef(
|
|
28
|
+
function ChartComponent({ data, className, style, loading, error, empty, ...options }, fwdRef) {
|
|
29
|
+
const container = react.useRef(null);
|
|
30
|
+
const instance = useChart(container, chartType, data, options);
|
|
31
|
+
react.useImperativeHandle(fwdRef, () => instance.current, [instance]);
|
|
32
|
+
react.useEffect(() => {
|
|
33
|
+
if (!instance.current) return;
|
|
34
|
+
if (loading) {
|
|
35
|
+
instance.current.setLoading(true);
|
|
36
|
+
} else if (error) {
|
|
37
|
+
instance.current.setError(typeof error === "string" ? error : void 0);
|
|
38
|
+
} else if (empty) {
|
|
39
|
+
instance.current.setEmpty(typeof empty === "string" ? empty : void 0);
|
|
40
|
+
} else {
|
|
41
|
+
instance.current.setLoading(false);
|
|
42
|
+
}
|
|
43
|
+
}, [loading, error, empty]);
|
|
44
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: container, className, style });
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
Component.displayName = displayName;
|
|
48
|
+
return Component;
|
|
49
|
+
}
|
|
50
|
+
var LineChart = createChartComponent(core.lineChartType, "LineChart");
|
|
51
|
+
var BarChart = createChartComponent(core.barChartType, "BarChart");
|
|
52
|
+
var StackedBarChart = createChartComponent(core.stackedBarChartType, "StackedBarChart");
|
|
53
|
+
var HorizontalBarChart = createChartComponent(core.horizontalBarChartType, "HorizontalBarChart");
|
|
54
|
+
var PieChart = createChartComponent(core.pieChartType, "PieChart");
|
|
55
|
+
var DonutChart = createChartComponent(core.donutChartType, "DonutChart");
|
|
56
|
+
var ScatterChart = createChartComponent(core.scatterChartType, "ScatterChart");
|
|
57
|
+
var SparklineChart = createChartComponent(core.sparklineChartType, "SparklineChart");
|
|
58
|
+
var AreaChart = createChartComponent(core.areaChartType, "AreaChart");
|
|
59
|
+
var RadarChart = createChartComponent(core.radarChartType, "RadarChart");
|
|
60
|
+
var BubbleChart = createChartComponent(core.bubbleChartType, "BubbleChart");
|
|
61
|
+
var CandlestickChart = createChartComponent(core.candlestickChartType, "CandlestickChart");
|
|
62
|
+
var GaugeChart = createChartComponent(core.gaugeChartType, "GaugeChart");
|
|
63
|
+
var WaterfallChart = createChartComponent(core.waterfallChartType, "WaterfallChart");
|
|
64
|
+
var FunnelChart = createChartComponent(core.funnelChartType, "FunnelChart");
|
|
65
|
+
var HeatmapChart = createChartComponent(core.heatmapChartType, "HeatmapChart");
|
|
66
|
+
var BoxplotChart = createChartComponent(core.boxplotChartType, "BoxplotChart");
|
|
67
|
+
var HistogramChart = createChartComponent(core.histogramChartType, "HistogramChart");
|
|
68
|
+
var TreemapChart = createChartComponent(core.treemapChartType, "TreemapChart");
|
|
69
|
+
var PolarChart = createChartComponent(core.polarChartType, "PolarChart");
|
|
70
|
+
var RadialBarChart = createChartComponent(core.radialBarChartType, "RadialBarChart");
|
|
71
|
+
var LollipopChart = createChartComponent(core.lollipopChartType, "LollipopChart");
|
|
72
|
+
var BulletChart = createChartComponent(core.bulletChartType, "BulletChart");
|
|
73
|
+
var DumbbellChart = createChartComponent(core.dumbbellChartType, "DumbbellChart");
|
|
74
|
+
var CalendarChart = createChartComponent(core.calendarChartType, "CalendarChart");
|
|
75
|
+
var ComboChart = createChartComponent(core.comboChartType, "ComboChart");
|
|
76
|
+
var SankeyChart = createChartComponent(core.sankeyChartType, "SankeyChart");
|
|
77
|
+
var SunburstChart = createChartComponent(core.sunburstChartType, "SunburstChart");
|
|
78
|
+
var TreeChart = createChartComponent(core.treeChartType, "TreeChart");
|
|
79
|
+
var GraphChart = createChartComponent(core.graphChartType, "GraphChart");
|
|
80
|
+
var ParallelChart = createChartComponent(core.parallelChartType, "ParallelChart");
|
|
81
|
+
var ThemeRiverChart = createChartComponent(core.themeRiverChartType, "ThemeRiverChart");
|
|
82
|
+
var PictorialBarChart = createChartComponent(core.pictorialBarChartType, "PictorialBarChart");
|
|
83
|
+
var ChordChart = createChartComponent(core.chordChartType, "ChordChart");
|
|
84
|
+
var GeoChart = createChartComponent(core.geoChartType, "GeoChart");
|
|
85
|
+
var LinesChart = createChartComponent(core.linesChartType, "LinesChart");
|
|
86
|
+
var MatrixChart = createChartComponent(core.matrixChartType, "MatrixChart");
|
|
87
|
+
var CustomChart = createChartComponent(core.customChartType, "CustomChart");
|
|
88
|
+
var OHLCChart = createChartComponent(core.ohlcChartType, "OHLCChart");
|
|
89
|
+
var StepChart = createChartComponent(core.stepChartType, "StepChart");
|
|
90
|
+
var VolumeChart = createChartComponent(core.volumeChartType, "VolumeChart");
|
|
91
|
+
var RangeChart = createChartComponent(core.rangeChartType, "RangeChart");
|
|
92
|
+
var BaselineChart = createChartComponent(core.baselineChartType, "BaselineChart");
|
|
93
|
+
var KagiChart = createChartComponent(core.kagiChartType, "KagiChart");
|
|
94
|
+
var RenkoChart = createChartComponent(core.renkoChartType, "RenkoChart");
|
|
95
|
+
var Chart = react.forwardRef(
|
|
96
|
+
function Chart2({ type, data, className, style, loading, error, empty, ...options }, fwdRef) {
|
|
97
|
+
const container = react.useRef(null);
|
|
98
|
+
const instance = useChart(container, type, data, options);
|
|
99
|
+
react.useImperativeHandle(fwdRef, () => instance.current, [instance]);
|
|
100
|
+
react.useEffect(() => {
|
|
101
|
+
if (!instance.current) return;
|
|
102
|
+
if (loading) {
|
|
103
|
+
instance.current.setLoading(true);
|
|
104
|
+
} else if (error) {
|
|
105
|
+
instance.current.setError(typeof error === "string" ? error : void 0);
|
|
106
|
+
} else if (empty) {
|
|
107
|
+
instance.current.setEmpty(typeof empty === "string" ? empty : void 0);
|
|
108
|
+
} else {
|
|
109
|
+
instance.current.setLoading(false);
|
|
110
|
+
}
|
|
111
|
+
}, [loading, error, empty]);
|
|
112
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: container, className, style });
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
Object.defineProperty(exports, "CORPORATE_THEME", {
|
|
117
|
+
enumerable: true,
|
|
118
|
+
get: function () { return core.CORPORATE_THEME; }
|
|
119
|
+
});
|
|
120
|
+
Object.defineProperty(exports, "DARK_THEME", {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function () { return core.DARK_THEME; }
|
|
123
|
+
});
|
|
124
|
+
Object.defineProperty(exports, "EDITORIAL_THEME", {
|
|
125
|
+
enumerable: true,
|
|
126
|
+
get: function () { return core.EDITORIAL_THEME; }
|
|
127
|
+
});
|
|
128
|
+
Object.defineProperty(exports, "LIGHT_THEME", {
|
|
129
|
+
enumerable: true,
|
|
130
|
+
get: function () { return core.LIGHT_THEME; }
|
|
131
|
+
});
|
|
132
|
+
Object.defineProperty(exports, "OCEAN_THEME", {
|
|
133
|
+
enumerable: true,
|
|
134
|
+
get: function () { return core.OCEAN_THEME; }
|
|
135
|
+
});
|
|
136
|
+
Object.defineProperty(exports, "PALETTE", {
|
|
137
|
+
enumerable: true,
|
|
138
|
+
get: function () { return core.PALETTE; }
|
|
139
|
+
});
|
|
140
|
+
Object.defineProperty(exports, "SAAS_THEME", {
|
|
141
|
+
enumerable: true,
|
|
142
|
+
get: function () { return core.SAAS_THEME; }
|
|
143
|
+
});
|
|
144
|
+
Object.defineProperty(exports, "STARTUP_THEME", {
|
|
145
|
+
enumerable: true,
|
|
146
|
+
get: function () { return core.STARTUP_THEME; }
|
|
147
|
+
});
|
|
148
|
+
Object.defineProperty(exports, "THEME_PRESETS", {
|
|
149
|
+
enumerable: true,
|
|
150
|
+
get: function () { return core.THEME_PRESETS; }
|
|
151
|
+
});
|
|
152
|
+
Object.defineProperty(exports, "applyTheme", {
|
|
153
|
+
enumerable: true,
|
|
154
|
+
get: function () { return core.applyTheme; }
|
|
155
|
+
});
|
|
156
|
+
Object.defineProperty(exports, "areaChartType", {
|
|
157
|
+
enumerable: true,
|
|
158
|
+
get: function () { return core.areaChartType; }
|
|
159
|
+
});
|
|
160
|
+
Object.defineProperty(exports, "barChartType", {
|
|
161
|
+
enumerable: true,
|
|
162
|
+
get: function () { return core.barChartType; }
|
|
163
|
+
});
|
|
164
|
+
Object.defineProperty(exports, "baselineChartType", {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
get: function () { return core.baselineChartType; }
|
|
167
|
+
});
|
|
168
|
+
Object.defineProperty(exports, "boxplotChartType", {
|
|
169
|
+
enumerable: true,
|
|
170
|
+
get: function () { return core.boxplotChartType; }
|
|
171
|
+
});
|
|
172
|
+
Object.defineProperty(exports, "bubbleChartType", {
|
|
173
|
+
enumerable: true,
|
|
174
|
+
get: function () { return core.bubbleChartType; }
|
|
175
|
+
});
|
|
176
|
+
Object.defineProperty(exports, "bulletChartType", {
|
|
177
|
+
enumerable: true,
|
|
178
|
+
get: function () { return core.bulletChartType; }
|
|
179
|
+
});
|
|
180
|
+
Object.defineProperty(exports, "calendarChartType", {
|
|
181
|
+
enumerable: true,
|
|
182
|
+
get: function () { return core.calendarChartType; }
|
|
183
|
+
});
|
|
184
|
+
Object.defineProperty(exports, "candlestickChartType", {
|
|
185
|
+
enumerable: true,
|
|
186
|
+
get: function () { return core.candlestickChartType; }
|
|
187
|
+
});
|
|
188
|
+
Object.defineProperty(exports, "chordChartType", {
|
|
189
|
+
enumerable: true,
|
|
190
|
+
get: function () { return core.chordChartType; }
|
|
191
|
+
});
|
|
192
|
+
Object.defineProperty(exports, "comboChartType", {
|
|
193
|
+
enumerable: true,
|
|
194
|
+
get: function () { return core.comboChartType; }
|
|
195
|
+
});
|
|
196
|
+
Object.defineProperty(exports, "customChartType", {
|
|
197
|
+
enumerable: true,
|
|
198
|
+
get: function () { return core.customChartType; }
|
|
199
|
+
});
|
|
200
|
+
Object.defineProperty(exports, "donutChartType", {
|
|
201
|
+
enumerable: true,
|
|
202
|
+
get: function () { return core.donutChartType; }
|
|
203
|
+
});
|
|
204
|
+
Object.defineProperty(exports, "dumbbellChartType", {
|
|
205
|
+
enumerable: true,
|
|
206
|
+
get: function () { return core.dumbbellChartType; }
|
|
207
|
+
});
|
|
208
|
+
Object.defineProperty(exports, "formatPercent", {
|
|
209
|
+
enumerable: true,
|
|
210
|
+
get: function () { return core.formatPercent; }
|
|
211
|
+
});
|
|
212
|
+
Object.defineProperty(exports, "formatValue", {
|
|
213
|
+
enumerable: true,
|
|
214
|
+
get: function () { return core.formatValue; }
|
|
215
|
+
});
|
|
216
|
+
Object.defineProperty(exports, "funnelChartType", {
|
|
217
|
+
enumerable: true,
|
|
218
|
+
get: function () { return core.funnelChartType; }
|
|
219
|
+
});
|
|
220
|
+
Object.defineProperty(exports, "gaugeChartType", {
|
|
221
|
+
enumerable: true,
|
|
222
|
+
get: function () { return core.gaugeChartType; }
|
|
223
|
+
});
|
|
224
|
+
Object.defineProperty(exports, "geoChartType", {
|
|
225
|
+
enumerable: true,
|
|
226
|
+
get: function () { return core.geoChartType; }
|
|
227
|
+
});
|
|
228
|
+
Object.defineProperty(exports, "graphChartType", {
|
|
229
|
+
enumerable: true,
|
|
230
|
+
get: function () { return core.graphChartType; }
|
|
231
|
+
});
|
|
232
|
+
Object.defineProperty(exports, "heatmapChartType", {
|
|
233
|
+
enumerable: true,
|
|
234
|
+
get: function () { return core.heatmapChartType; }
|
|
235
|
+
});
|
|
236
|
+
Object.defineProperty(exports, "histogramChartType", {
|
|
237
|
+
enumerable: true,
|
|
238
|
+
get: function () { return core.histogramChartType; }
|
|
239
|
+
});
|
|
240
|
+
Object.defineProperty(exports, "horizontalBarChartType", {
|
|
241
|
+
enumerable: true,
|
|
242
|
+
get: function () { return core.horizontalBarChartType; }
|
|
243
|
+
});
|
|
244
|
+
Object.defineProperty(exports, "kagiChartType", {
|
|
245
|
+
enumerable: true,
|
|
246
|
+
get: function () { return core.kagiChartType; }
|
|
247
|
+
});
|
|
248
|
+
Object.defineProperty(exports, "lineChartType", {
|
|
249
|
+
enumerable: true,
|
|
250
|
+
get: function () { return core.lineChartType; }
|
|
251
|
+
});
|
|
252
|
+
Object.defineProperty(exports, "linesChartType", {
|
|
253
|
+
enumerable: true,
|
|
254
|
+
get: function () { return core.linesChartType; }
|
|
255
|
+
});
|
|
256
|
+
Object.defineProperty(exports, "lollipopChartType", {
|
|
257
|
+
enumerable: true,
|
|
258
|
+
get: function () { return core.lollipopChartType; }
|
|
259
|
+
});
|
|
260
|
+
Object.defineProperty(exports, "matrixChartType", {
|
|
261
|
+
enumerable: true,
|
|
262
|
+
get: function () { return core.matrixChartType; }
|
|
263
|
+
});
|
|
264
|
+
Object.defineProperty(exports, "ohlcChartType", {
|
|
265
|
+
enumerable: true,
|
|
266
|
+
get: function () { return core.ohlcChartType; }
|
|
267
|
+
});
|
|
268
|
+
Object.defineProperty(exports, "parallelChartType", {
|
|
269
|
+
enumerable: true,
|
|
270
|
+
get: function () { return core.parallelChartType; }
|
|
271
|
+
});
|
|
272
|
+
Object.defineProperty(exports, "pictorialBarChartType", {
|
|
273
|
+
enumerable: true,
|
|
274
|
+
get: function () { return core.pictorialBarChartType; }
|
|
275
|
+
});
|
|
276
|
+
Object.defineProperty(exports, "pieChartType", {
|
|
277
|
+
enumerable: true,
|
|
278
|
+
get: function () { return core.pieChartType; }
|
|
279
|
+
});
|
|
280
|
+
Object.defineProperty(exports, "polarChartType", {
|
|
281
|
+
enumerable: true,
|
|
282
|
+
get: function () { return core.polarChartType; }
|
|
283
|
+
});
|
|
284
|
+
Object.defineProperty(exports, "radarChartType", {
|
|
285
|
+
enumerable: true,
|
|
286
|
+
get: function () { return core.radarChartType; }
|
|
287
|
+
});
|
|
288
|
+
Object.defineProperty(exports, "radialBarChartType", {
|
|
289
|
+
enumerable: true,
|
|
290
|
+
get: function () { return core.radialBarChartType; }
|
|
291
|
+
});
|
|
292
|
+
Object.defineProperty(exports, "rangeChartType", {
|
|
293
|
+
enumerable: true,
|
|
294
|
+
get: function () { return core.rangeChartType; }
|
|
295
|
+
});
|
|
296
|
+
Object.defineProperty(exports, "renkoChartType", {
|
|
297
|
+
enumerable: true,
|
|
298
|
+
get: function () { return core.renkoChartType; }
|
|
299
|
+
});
|
|
300
|
+
Object.defineProperty(exports, "resolveTheme", {
|
|
301
|
+
enumerable: true,
|
|
302
|
+
get: function () { return core.resolveTheme; }
|
|
303
|
+
});
|
|
304
|
+
Object.defineProperty(exports, "sankeyChartType", {
|
|
305
|
+
enumerable: true,
|
|
306
|
+
get: function () { return core.sankeyChartType; }
|
|
307
|
+
});
|
|
308
|
+
Object.defineProperty(exports, "scatterChartType", {
|
|
309
|
+
enumerable: true,
|
|
310
|
+
get: function () { return core.scatterChartType; }
|
|
311
|
+
});
|
|
312
|
+
Object.defineProperty(exports, "sparklineChartType", {
|
|
313
|
+
enumerable: true,
|
|
314
|
+
get: function () { return core.sparklineChartType; }
|
|
315
|
+
});
|
|
316
|
+
Object.defineProperty(exports, "stackedBarChartType", {
|
|
317
|
+
enumerable: true,
|
|
318
|
+
get: function () { return core.stackedBarChartType; }
|
|
319
|
+
});
|
|
320
|
+
Object.defineProperty(exports, "stepChartType", {
|
|
321
|
+
enumerable: true,
|
|
322
|
+
get: function () { return core.stepChartType; }
|
|
323
|
+
});
|
|
324
|
+
Object.defineProperty(exports, "sunburstChartType", {
|
|
325
|
+
enumerable: true,
|
|
326
|
+
get: function () { return core.sunburstChartType; }
|
|
327
|
+
});
|
|
328
|
+
Object.defineProperty(exports, "themeRiverChartType", {
|
|
329
|
+
enumerable: true,
|
|
330
|
+
get: function () { return core.themeRiverChartType; }
|
|
331
|
+
});
|
|
332
|
+
Object.defineProperty(exports, "treeChartType", {
|
|
333
|
+
enumerable: true,
|
|
334
|
+
get: function () { return core.treeChartType; }
|
|
335
|
+
});
|
|
336
|
+
Object.defineProperty(exports, "treemapChartType", {
|
|
337
|
+
enumerable: true,
|
|
338
|
+
get: function () { return core.treemapChartType; }
|
|
339
|
+
});
|
|
340
|
+
Object.defineProperty(exports, "volumeChartType", {
|
|
341
|
+
enumerable: true,
|
|
342
|
+
get: function () { return core.volumeChartType; }
|
|
343
|
+
});
|
|
344
|
+
Object.defineProperty(exports, "waterfallChartType", {
|
|
345
|
+
enumerable: true,
|
|
346
|
+
get: function () { return core.waterfallChartType; }
|
|
347
|
+
});
|
|
348
|
+
exports.AreaChart = AreaChart;
|
|
349
|
+
exports.BarChart = BarChart;
|
|
350
|
+
exports.BaselineChart = BaselineChart;
|
|
351
|
+
exports.BoxplotChart = BoxplotChart;
|
|
352
|
+
exports.BubbleChart = BubbleChart;
|
|
353
|
+
exports.BulletChart = BulletChart;
|
|
354
|
+
exports.CalendarChart = CalendarChart;
|
|
355
|
+
exports.CandlestickChart = CandlestickChart;
|
|
356
|
+
exports.Chart = Chart;
|
|
357
|
+
exports.ChordChart = ChordChart;
|
|
358
|
+
exports.ComboChart = ComboChart;
|
|
359
|
+
exports.CustomChart = CustomChart;
|
|
360
|
+
exports.DonutChart = DonutChart;
|
|
361
|
+
exports.DumbbellChart = DumbbellChart;
|
|
362
|
+
exports.FunnelChart = FunnelChart;
|
|
363
|
+
exports.GaugeChart = GaugeChart;
|
|
364
|
+
exports.GeoChart = GeoChart;
|
|
365
|
+
exports.GraphChart = GraphChart;
|
|
366
|
+
exports.HeatmapChart = HeatmapChart;
|
|
367
|
+
exports.HistogramChart = HistogramChart;
|
|
368
|
+
exports.HorizontalBarChart = HorizontalBarChart;
|
|
369
|
+
exports.KagiChart = KagiChart;
|
|
370
|
+
exports.LineChart = LineChart;
|
|
371
|
+
exports.LinesChart = LinesChart;
|
|
372
|
+
exports.LollipopChart = LollipopChart;
|
|
373
|
+
exports.MatrixChart = MatrixChart;
|
|
374
|
+
exports.OHLCChart = OHLCChart;
|
|
375
|
+
exports.ParallelChart = ParallelChart;
|
|
376
|
+
exports.PictorialBarChart = PictorialBarChart;
|
|
377
|
+
exports.PieChart = PieChart;
|
|
378
|
+
exports.PolarChart = PolarChart;
|
|
379
|
+
exports.RadarChart = RadarChart;
|
|
380
|
+
exports.RadialBarChart = RadialBarChart;
|
|
381
|
+
exports.RangeChart = RangeChart;
|
|
382
|
+
exports.RenkoChart = RenkoChart;
|
|
383
|
+
exports.SankeyChart = SankeyChart;
|
|
384
|
+
exports.ScatterChart = ScatterChart;
|
|
385
|
+
exports.SparklineChart = SparklineChart;
|
|
386
|
+
exports.StackedBarChart = StackedBarChart;
|
|
387
|
+
exports.StepChart = StepChart;
|
|
388
|
+
exports.SunburstChart = SunburstChart;
|
|
389
|
+
exports.ThemeRiverChart = ThemeRiverChart;
|
|
390
|
+
exports.TreeChart = TreeChart;
|
|
391
|
+
exports.TreemapChart = TreemapChart;
|
|
392
|
+
exports.VolumeChart = VolumeChart;
|
|
393
|
+
exports.WaterfallChart = WaterfallChart;
|
|
394
|
+
exports.useChart = useChart;
|
|
395
|
+
//# sourceMappingURL=index.cjs.map
|
|
396
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"names":["useRef","useEffect","createChart","forwardRef","useImperativeHandle","jsx","lineChartType","barChartType","stackedBarChartType","horizontalBarChartType","pieChartType","donutChartType","scatterChartType","sparklineChartType","areaChartType","radarChartType","bubbleChartType","candlestickChartType","gaugeChartType","waterfallChartType","funnelChartType","heatmapChartType","boxplotChartType","histogramChartType","treemapChartType","polarChartType","radialBarChartType","lollipopChartType","bulletChartType","dumbbellChartType","calendarChartType","comboChartType","sankeyChartType","sunburstChartType","treeChartType","graphChartType","parallelChartType","themeRiverChartType","pictorialBarChartType","chordChartType","geoChartType","linesChartType","matrixChartType","customChartType","ohlcChartType","stepChartType","volumeChartType","rangeChartType","baselineChartType","kagiChartType","renkoChartType","Chart"],"mappings":";;;;;;;AAyBA,SAAS,QAAA,CACP,GAAA,EACA,SAAA,EACA,IAAA,EACA,OAAA,EACuC;AACvC,EAAA,MAAM,QAAA,GAAWA,aAA6B,IAAI,CAAA;AAElD,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,IAAI,CAAC,IAAI,OAAA,EAAS;AAElB,IAAA,QAAA,CAAS,UAAUC,gBAAA,CAAY,GAAA,CAAI,OAAA,EAAS,SAAA,EAAW,MAAM,OAAO,CAAA;AAEpE,IAAA,OAAO,MAAM;AACX,MAAA,QAAA,CAAS,SAAS,OAAA,EAAQ;AAC1B,MAAA,QAAA,CAAS,OAAA,GAAU,IAAA;AAAA,IACrB,CAAA;AAAA,EAEF,CAAA,EAAG,CAAC,GAAA,CAAI,OAAO,CAAC,CAAA;AAEhB,EAAAD,eAAA,CAAU,MAAM;AACd,IAAA,QAAA,CAAS,OAAA,EAAS,QAAQ,IAAI,CAAA;AAAA,EAChC,CAAA,EAAG,CAAC,IAAI,CAAC,CAAA;AAET,EAAAA,eAAA,CAAU,MAAM;AACd,IAAA,QAAA,CAAS,OAAA,EAAS,WAAW,OAAO,CAAA;AAAA,EACtC,CAAA,EAAG,CAAC,OAAO,CAAC,CAAA;AAEZ,EAAA,OAAO,QAAA;AACT;AAsBA,SAAS,oBAAA,CAAqB,WAA4B,WAAA,EAAqB;AAC7E,EAAA,MAAM,SAAA,GAAYE,gBAAA;AAAA,IAChB,SAAS,cAAA,CACP,EAAE,IAAA,EAAM,SAAA,EAAW,KAAA,EAAO,OAAA,EAAS,KAAA,EAAO,KAAA,EAA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\n type Ref,\n} from 'react'\nimport {\n createChart,\n lineChartType, barChartType, stackedBarChartType, horizontalBarChartType,\n pieChartType, donutChartType, scatterChartType, sparklineChartType,\n areaChartType, radarChartType, bubbleChartType, candlestickChartType,\n gaugeChartType, waterfallChartType, funnelChartType, heatmapChartType,\n boxplotChartType, histogramChartType, treemapChartType, polarChartType,\n radialBarChartType, lollipopChartType, bulletChartType, dumbbellChartType,\n calendarChartType, comboChartType, sankeyChartType,\n sunburstChartType, treeChartType, graphChartType, parallelChartType,\n themeRiverChartType, pictorialBarChartType, chordChartType,\n geoChartType, linesChartType, matrixChartType, customChartType,\n ohlcChartType, stepChartType, volumeChartType, rangeChartType,\n baselineChartType, kagiChartType, renkoChartType,\n type ChartData, type ChartOptions, type ChartInstance, type ChartTypePlugin,\n} from '@chartts/core'\n\n// ---------------------------------------------------------------------------\n// Shared hook — manages chart lifecycle, data updates, and options\n// ---------------------------------------------------------------------------\n\nfunction useChart(\n ref: React.RefObject<HTMLDivElement | null>,\n chartType: ChartTypePlugin,\n data: ChartData,\n options: ChartOptions,\n): React.RefObject<ChartInstance | null> {\n const instance = useRef<ChartInstance | null>(null)\n\n useEffect(() => {\n if (!ref.current) return\n\n instance.current = createChart(ref.current, chartType, data, options)\n\n return () => {\n instance.current?.destroy()\n instance.current = null\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [ref.current])\n\n useEffect(() => {\n instance.current?.setData(data)\n }, [data])\n\n useEffect(() => {\n instance.current?.setOptions(options)\n }, [options])\n\n return instance\n}\n\n// ---------------------------------------------------------------------------\n// Props\n// ---------------------------------------------------------------------------\n\nexport interface ChartProps extends ChartOptions {\n data: ChartData\n className?: string\n style?: React.CSSProperties\n /** Show loading skeleton instead of chart */\n loading?: boolean\n /** Show error state with optional message */\n error?: string | boolean\n /** Show empty state with optional message */\n empty?: string | boolean\n}\n\n// ---------------------------------------------------------------------------\n// Factory — generates typed chart components from chart type plugins\n// ---------------------------------------------------------------------------\n\nfunction createChartComponent(chartType: ChartTypePlugin, displayName: string) {\n const Component = forwardRef<ChartInstance, ChartProps>(\n function ChartComponent(\n { data, className, style, loading, error, empty, ...options }: ChartProps,\n fwdRef: Ref<ChartInstance>,\n ) {\n const container = useRef<HTMLDivElement | null>(null)\n const instance = useChart(container, chartType, data, options)\n\n useImperativeHandle(fwdRef, () => instance.current!, [instance])\n\n // Handle state props\n useEffect(() => {\n if (!instance.current) return\n if (loading) {\n instance.current.setLoading(true)\n } else if (error) {\n instance.current.setError(typeof error === 'string' ? error : undefined)\n } else if (empty) {\n instance.current.setEmpty(typeof empty === 'string' ? empty : undefined)\n } else {\n instance.current.setLoading(false)\n }\n }, [loading, error, empty])\n\n return <div ref={container} className={className} style={style} />\n },\n )\n Component.displayName = displayName\n return Component\n}\n\n// ---------------------------------------------------------------------------\n// Chart components — one per chart type\n// ---------------------------------------------------------------------------\n\nexport const LineChart = createChartComponent(lineChartType, 'LineChart')\nexport const BarChart = createChartComponent(barChartType, 'BarChart')\nexport const StackedBarChart = createChartComponent(stackedBarChartType, 'StackedBarChart')\nexport const HorizontalBarChart = createChartComponent(horizontalBarChartType, 'HorizontalBarChart')\nexport const PieChart = createChartComponent(pieChartType, 'PieChart')\nexport const DonutChart = createChartComponent(donutChartType, 'DonutChart')\nexport const ScatterChart = createChartComponent(scatterChartType, 'ScatterChart')\nexport const SparklineChart = createChartComponent(sparklineChartType, 'SparklineChart')\nexport const AreaChart = createChartComponent(areaChartType, 'AreaChart')\nexport const RadarChart = createChartComponent(radarChartType, 'RadarChart')\nexport const BubbleChart = createChartComponent(bubbleChartType, 'BubbleChart')\nexport const CandlestickChart = createChartComponent(candlestickChartType, 'CandlestickChart')\nexport const GaugeChart = createChartComponent(gaugeChartType, 'GaugeChart')\nexport const WaterfallChart = createChartComponent(waterfallChartType, 'WaterfallChart')\nexport const FunnelChart = createChartComponent(funnelChartType, 'FunnelChart')\nexport const HeatmapChart = createChartComponent(heatmapChartType, 'HeatmapChart')\nexport const BoxplotChart = createChartComponent(boxplotChartType, 'BoxplotChart')\nexport const HistogramChart = createChartComponent(histogramChartType, 'HistogramChart')\nexport const TreemapChart = createChartComponent(treemapChartType, 'TreemapChart')\nexport const PolarChart = createChartComponent(polarChartType, 'PolarChart')\nexport const RadialBarChart = createChartComponent(radialBarChartType, 'RadialBarChart')\nexport const LollipopChart = createChartComponent(lollipopChartType, 'LollipopChart')\nexport const BulletChart = createChartComponent(bulletChartType, 'BulletChart')\nexport const DumbbellChart = createChartComponent(dumbbellChartType, 'DumbbellChart')\nexport const CalendarChart = createChartComponent(calendarChartType, 'CalendarChart')\nexport const ComboChart = createChartComponent(comboChartType, 'ComboChart')\nexport const SankeyChart = createChartComponent(sankeyChartType, 'SankeyChart')\nexport const SunburstChart = createChartComponent(sunburstChartType, 'SunburstChart')\nexport const TreeChart = createChartComponent(treeChartType, 'TreeChart')\nexport const GraphChart = createChartComponent(graphChartType, 'GraphChart')\nexport const ParallelChart = createChartComponent(parallelChartType, 'ParallelChart')\nexport const ThemeRiverChart = createChartComponent(themeRiverChartType, 'ThemeRiverChart')\nexport const PictorialBarChart = createChartComponent(pictorialBarChartType, 'PictorialBarChart')\nexport const ChordChart = createChartComponent(chordChartType, 'ChordChart')\nexport const GeoChart = createChartComponent(geoChartType, 'GeoChart')\nexport const LinesChart = createChartComponent(linesChartType, 'LinesChart')\nexport const MatrixChart = createChartComponent(matrixChartType, 'MatrixChart')\nexport const CustomChart = createChartComponent(customChartType, 'CustomChart')\nexport const OHLCChart = createChartComponent(ohlcChartType, 'OHLCChart')\nexport const StepChart = createChartComponent(stepChartType, 'StepChart')\nexport const VolumeChart = createChartComponent(volumeChartType, 'VolumeChart')\nexport const RangeChart = createChartComponent(rangeChartType, 'RangeChart')\nexport const BaselineChart = createChartComponent(baselineChartType, 'BaselineChart')\nexport const KagiChart = createChartComponent(kagiChartType, 'KagiChart')\nexport const RenkoChart = createChartComponent(renkoChartType, 'RenkoChart')\n\n// ---------------------------------------------------------------------------\n// Generic Chart — pass any ChartTypePlugin\n// ---------------------------------------------------------------------------\n\nexport interface GenericChartProps extends ChartProps {\n type: ChartTypePlugin\n}\n\nexport const Chart = forwardRef<ChartInstance, GenericChartProps>(\n function Chart(\n { type, data, className, style, loading, error, empty, ...options }: GenericChartProps,\n fwdRef: Ref<ChartInstance>,\n ) {\n const container = useRef<HTMLDivElement | null>(null)\n const instance = useChart(container, type, data, options)\n\n useImperativeHandle(fwdRef, () => instance.current!, [instance])\n\n useEffect(() => {\n if (!instance.current) return\n if (loading) {\n instance.current.setLoading(true)\n } else if (error) {\n instance.current.setError(typeof error === 'string' ? error : undefined)\n } else if (empty) {\n instance.current.setEmpty(typeof empty === 'string' ? empty : undefined)\n } else {\n instance.current.setLoading(false)\n }\n }, [loading, error, empty])\n\n return <div ref={container} className={className} style={style} />\n },\n)\n\n// ---------------------------------------------------------------------------\n// useChart hook for advanced use cases\n// ---------------------------------------------------------------------------\n\nexport { useChart }\n\n// ---------------------------------------------------------------------------\n// Re-exports from core\n// ---------------------------------------------------------------------------\n\nexport {\n // Chart type plugins\n lineChartType, barChartType, stackedBarChartType, horizontalBarChartType,\n pieChartType, donutChartType, scatterChartType, sparklineChartType,\n areaChartType, radarChartType, bubbleChartType, candlestickChartType,\n gaugeChartType, waterfallChartType, funnelChartType, heatmapChartType,\n boxplotChartType, histogramChartType, treemapChartType, polarChartType,\n radialBarChartType, lollipopChartType, bulletChartType, dumbbellChartType,\n calendarChartType, comboChartType, sankeyChartType,\n sunburstChartType, treeChartType, graphChartType, parallelChartType,\n themeRiverChartType, pictorialBarChartType, chordChartType,\n geoChartType, linesChartType, matrixChartType, customChartType,\n ohlcChartType, stepChartType, volumeChartType, rangeChartType,\n baselineChartType, kagiChartType, renkoChartType,\n // Theme\n resolveTheme, applyTheme,\n LIGHT_THEME, DARK_THEME, PALETTE,\n THEME_PRESETS, CORPORATE_THEME, SAAS_THEME, STARTUP_THEME, EDITORIAL_THEME, OCEAN_THEME,\n // Formatters\n formatValue, formatPercent,\n} from '@chartts/core'\nexport type { ChartData, ChartOptions, ChartInstance, ChartTypePlugin, ThemeConfig, Series } from '@chartts/core'\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ChartOptions, ChartData, ChartInstance, ChartTypePlugin } from '@chartts/core';
|
|
3
|
+
export { CORPORATE_THEME, ChartData, ChartInstance, ChartOptions, ChartTypePlugin, DARK_THEME, EDITORIAL_THEME, LIGHT_THEME, OCEAN_THEME, PALETTE, SAAS_THEME, STARTUP_THEME, Series, THEME_PRESETS, ThemeConfig, applyTheme, areaChartType, barChartType, baselineChartType, boxplotChartType, bubbleChartType, bulletChartType, calendarChartType, candlestickChartType, chordChartType, comboChartType, customChartType, donutChartType, dumbbellChartType, formatPercent, formatValue, funnelChartType, gaugeChartType, geoChartType, graphChartType, heatmapChartType, histogramChartType, horizontalBarChartType, kagiChartType, lineChartType, linesChartType, lollipopChartType, matrixChartType, ohlcChartType, parallelChartType, pictorialBarChartType, pieChartType, polarChartType, radarChartType, radialBarChartType, rangeChartType, renkoChartType, resolveTheme, sankeyChartType, scatterChartType, sparklineChartType, stackedBarChartType, stepChartType, sunburstChartType, themeRiverChartType, treeChartType, treemapChartType, volumeChartType, waterfallChartType } from '@chartts/core';
|
|
4
|
+
|
|
5
|
+
declare function useChart(ref: React.RefObject<HTMLDivElement | null>, chartType: ChartTypePlugin, data: ChartData, options: ChartOptions): React.RefObject<ChartInstance | null>;
|
|
6
|
+
interface ChartProps extends ChartOptions {
|
|
7
|
+
data: ChartData;
|
|
8
|
+
className?: string;
|
|
9
|
+
style?: React.CSSProperties;
|
|
10
|
+
/** Show loading skeleton instead of chart */
|
|
11
|
+
loading?: boolean;
|
|
12
|
+
/** Show error state with optional message */
|
|
13
|
+
error?: string | boolean;
|
|
14
|
+
/** Show empty state with optional message */
|
|
15
|
+
empty?: string | boolean;
|
|
16
|
+
}
|
|
17
|
+
declare const LineChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
18
|
+
declare const BarChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
19
|
+
declare const StackedBarChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
20
|
+
declare const HorizontalBarChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
21
|
+
declare const PieChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
22
|
+
declare const DonutChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
23
|
+
declare const ScatterChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
24
|
+
declare const SparklineChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
25
|
+
declare const AreaChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
26
|
+
declare const RadarChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
27
|
+
declare const BubbleChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
28
|
+
declare const CandlestickChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
29
|
+
declare const GaugeChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
30
|
+
declare const WaterfallChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
31
|
+
declare const FunnelChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
32
|
+
declare const HeatmapChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
33
|
+
declare const BoxplotChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
34
|
+
declare const HistogramChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
35
|
+
declare const TreemapChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
36
|
+
declare const PolarChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
37
|
+
declare const RadialBarChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
38
|
+
declare const LollipopChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
39
|
+
declare const BulletChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
40
|
+
declare const DumbbellChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
41
|
+
declare const CalendarChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
42
|
+
declare const ComboChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
43
|
+
declare const SankeyChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
44
|
+
declare const SunburstChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
45
|
+
declare const TreeChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
46
|
+
declare const GraphChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
47
|
+
declare const ParallelChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
48
|
+
declare const ThemeRiverChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
49
|
+
declare const PictorialBarChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
50
|
+
declare const ChordChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
51
|
+
declare const GeoChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
52
|
+
declare const LinesChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
53
|
+
declare const MatrixChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
54
|
+
declare const CustomChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
55
|
+
declare const OHLCChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
56
|
+
declare const StepChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
57
|
+
declare const VolumeChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
58
|
+
declare const RangeChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
59
|
+
declare const BaselineChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
60
|
+
declare const KagiChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
61
|
+
declare const RenkoChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
62
|
+
interface GenericChartProps extends ChartProps {
|
|
63
|
+
type: ChartTypePlugin;
|
|
64
|
+
}
|
|
65
|
+
declare const Chart: react.ForwardRefExoticComponent<GenericChartProps & react.RefAttributes<ChartInstance>>;
|
|
66
|
+
|
|
67
|
+
export { AreaChart, BarChart, BaselineChart, BoxplotChart, BubbleChart, BulletChart, CalendarChart, CandlestickChart, Chart, type ChartProps, ChordChart, ComboChart, CustomChart, DonutChart, DumbbellChart, FunnelChart, GaugeChart, type GenericChartProps, GeoChart, GraphChart, HeatmapChart, HistogramChart, HorizontalBarChart, KagiChart, LineChart, LinesChart, LollipopChart, MatrixChart, OHLCChart, ParallelChart, PictorialBarChart, PieChart, PolarChart, RadarChart, RadialBarChart, RangeChart, RenkoChart, SankeyChart, ScatterChart, SparklineChart, StackedBarChart, StepChart, SunburstChart, ThemeRiverChart, TreeChart, TreemapChart, VolumeChart, WaterfallChart, useChart };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ChartOptions, ChartData, ChartInstance, ChartTypePlugin } from '@chartts/core';
|
|
3
|
+
export { CORPORATE_THEME, ChartData, ChartInstance, ChartOptions, ChartTypePlugin, DARK_THEME, EDITORIAL_THEME, LIGHT_THEME, OCEAN_THEME, PALETTE, SAAS_THEME, STARTUP_THEME, Series, THEME_PRESETS, ThemeConfig, applyTheme, areaChartType, barChartType, baselineChartType, boxplotChartType, bubbleChartType, bulletChartType, calendarChartType, candlestickChartType, chordChartType, comboChartType, customChartType, donutChartType, dumbbellChartType, formatPercent, formatValue, funnelChartType, gaugeChartType, geoChartType, graphChartType, heatmapChartType, histogramChartType, horizontalBarChartType, kagiChartType, lineChartType, linesChartType, lollipopChartType, matrixChartType, ohlcChartType, parallelChartType, pictorialBarChartType, pieChartType, polarChartType, radarChartType, radialBarChartType, rangeChartType, renkoChartType, resolveTheme, sankeyChartType, scatterChartType, sparklineChartType, stackedBarChartType, stepChartType, sunburstChartType, themeRiverChartType, treeChartType, treemapChartType, volumeChartType, waterfallChartType } from '@chartts/core';
|
|
4
|
+
|
|
5
|
+
declare function useChart(ref: React.RefObject<HTMLDivElement | null>, chartType: ChartTypePlugin, data: ChartData, options: ChartOptions): React.RefObject<ChartInstance | null>;
|
|
6
|
+
interface ChartProps extends ChartOptions {
|
|
7
|
+
data: ChartData;
|
|
8
|
+
className?: string;
|
|
9
|
+
style?: React.CSSProperties;
|
|
10
|
+
/** Show loading skeleton instead of chart */
|
|
11
|
+
loading?: boolean;
|
|
12
|
+
/** Show error state with optional message */
|
|
13
|
+
error?: string | boolean;
|
|
14
|
+
/** Show empty state with optional message */
|
|
15
|
+
empty?: string | boolean;
|
|
16
|
+
}
|
|
17
|
+
declare const LineChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
18
|
+
declare const BarChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
19
|
+
declare const StackedBarChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
20
|
+
declare const HorizontalBarChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
21
|
+
declare const PieChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
22
|
+
declare const DonutChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
23
|
+
declare const ScatterChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
24
|
+
declare const SparklineChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
25
|
+
declare const AreaChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
26
|
+
declare const RadarChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
27
|
+
declare const BubbleChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
28
|
+
declare const CandlestickChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
29
|
+
declare const GaugeChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
30
|
+
declare const WaterfallChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
31
|
+
declare const FunnelChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
32
|
+
declare const HeatmapChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
33
|
+
declare const BoxplotChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
34
|
+
declare const HistogramChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
35
|
+
declare const TreemapChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
36
|
+
declare const PolarChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
37
|
+
declare const RadialBarChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
38
|
+
declare const LollipopChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
39
|
+
declare const BulletChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
40
|
+
declare const DumbbellChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
41
|
+
declare const CalendarChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
42
|
+
declare const ComboChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
43
|
+
declare const SankeyChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
44
|
+
declare const SunburstChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
45
|
+
declare const TreeChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
46
|
+
declare const GraphChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
47
|
+
declare const ParallelChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
48
|
+
declare const ThemeRiverChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
49
|
+
declare const PictorialBarChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
50
|
+
declare const ChordChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
51
|
+
declare const GeoChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
52
|
+
declare const LinesChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
53
|
+
declare const MatrixChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
54
|
+
declare const CustomChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
55
|
+
declare const OHLCChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
56
|
+
declare const StepChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
57
|
+
declare const VolumeChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
58
|
+
declare const RangeChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
59
|
+
declare const BaselineChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
60
|
+
declare const KagiChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
61
|
+
declare const RenkoChart: react.ForwardRefExoticComponent<ChartProps & react.RefAttributes<ChartInstance>>;
|
|
62
|
+
interface GenericChartProps extends ChartProps {
|
|
63
|
+
type: ChartTypePlugin;
|
|
64
|
+
}
|
|
65
|
+
declare const Chart: react.ForwardRefExoticComponent<GenericChartProps & react.RefAttributes<ChartInstance>>;
|
|
66
|
+
|
|
67
|
+
export { AreaChart, BarChart, BaselineChart, BoxplotChart, BubbleChart, BulletChart, CalendarChart, CandlestickChart, Chart, type ChartProps, ChordChart, ComboChart, CustomChart, DonutChart, DumbbellChart, FunnelChart, GaugeChart, type GenericChartProps, GeoChart, GraphChart, HeatmapChart, HistogramChart, HorizontalBarChart, KagiChart, LineChart, LinesChart, LollipopChart, MatrixChart, OHLCChart, ParallelChart, PictorialBarChart, PieChart, PolarChart, RadarChart, RadialBarChart, RangeChart, RenkoChart, SankeyChart, ScatterChart, SparklineChart, StackedBarChart, StepChart, SunburstChart, ThemeRiverChart, TreeChart, TreemapChart, VolumeChart, WaterfallChart, useChart };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { forwardRef, useRef, useImperativeHandle, useEffect } from 'react';
|
|
2
|
+
import { createChart, lineChartType, barChartType, stackedBarChartType, horizontalBarChartType, pieChartType, donutChartType, scatterChartType, sparklineChartType, areaChartType, radarChartType, bubbleChartType, candlestickChartType, gaugeChartType, waterfallChartType, funnelChartType, heatmapChartType, boxplotChartType, histogramChartType, treemapChartType, polarChartType, radialBarChartType, lollipopChartType, bulletChartType, dumbbellChartType, calendarChartType, comboChartType, sankeyChartType, sunburstChartType, treeChartType, graphChartType, parallelChartType, themeRiverChartType, pictorialBarChartType, chordChartType, geoChartType, linesChartType, matrixChartType, customChartType, ohlcChartType, stepChartType, volumeChartType, rangeChartType, baselineChartType, kagiChartType, renkoChartType } from '@chartts/core';
|
|
3
|
+
export { CORPORATE_THEME, DARK_THEME, EDITORIAL_THEME, LIGHT_THEME, OCEAN_THEME, PALETTE, SAAS_THEME, STARTUP_THEME, THEME_PRESETS, applyTheme, areaChartType, barChartType, baselineChartType, boxplotChartType, bubbleChartType, bulletChartType, calendarChartType, candlestickChartType, chordChartType, comboChartType, customChartType, donutChartType, dumbbellChartType, formatPercent, formatValue, funnelChartType, gaugeChartType, geoChartType, graphChartType, heatmapChartType, histogramChartType, horizontalBarChartType, kagiChartType, lineChartType, linesChartType, lollipopChartType, matrixChartType, ohlcChartType, parallelChartType, pictorialBarChartType, pieChartType, polarChartType, radarChartType, radialBarChartType, rangeChartType, renkoChartType, resolveTheme, sankeyChartType, scatterChartType, sparklineChartType, stackedBarChartType, stepChartType, sunburstChartType, themeRiverChartType, treeChartType, treemapChartType, volumeChartType, waterfallChartType } from '@chartts/core';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
// src/index.tsx
|
|
7
|
+
function useChart(ref, chartType, data, options) {
|
|
8
|
+
const instance = useRef(null);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (!ref.current) return;
|
|
11
|
+
instance.current = createChart(ref.current, chartType, data, options);
|
|
12
|
+
return () => {
|
|
13
|
+
instance.current?.destroy();
|
|
14
|
+
instance.current = null;
|
|
15
|
+
};
|
|
16
|
+
}, [ref.current]);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
instance.current?.setData(data);
|
|
19
|
+
}, [data]);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
instance.current?.setOptions(options);
|
|
22
|
+
}, [options]);
|
|
23
|
+
return instance;
|
|
24
|
+
}
|
|
25
|
+
function createChartComponent(chartType, displayName) {
|
|
26
|
+
const Component = forwardRef(
|
|
27
|
+
function ChartComponent({ data, className, style, loading, error, empty, ...options }, fwdRef) {
|
|
28
|
+
const container = useRef(null);
|
|
29
|
+
const instance = useChart(container, chartType, data, options);
|
|
30
|
+
useImperativeHandle(fwdRef, () => instance.current, [instance]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (!instance.current) return;
|
|
33
|
+
if (loading) {
|
|
34
|
+
instance.current.setLoading(true);
|
|
35
|
+
} else if (error) {
|
|
36
|
+
instance.current.setError(typeof error === "string" ? error : void 0);
|
|
37
|
+
} else if (empty) {
|
|
38
|
+
instance.current.setEmpty(typeof empty === "string" ? empty : void 0);
|
|
39
|
+
} else {
|
|
40
|
+
instance.current.setLoading(false);
|
|
41
|
+
}
|
|
42
|
+
}, [loading, error, empty]);
|
|
43
|
+
return /* @__PURE__ */ jsx("div", { ref: container, className, style });
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
Component.displayName = displayName;
|
|
47
|
+
return Component;
|
|
48
|
+
}
|
|
49
|
+
var LineChart = createChartComponent(lineChartType, "LineChart");
|
|
50
|
+
var BarChart = createChartComponent(barChartType, "BarChart");
|
|
51
|
+
var StackedBarChart = createChartComponent(stackedBarChartType, "StackedBarChart");
|
|
52
|
+
var HorizontalBarChart = createChartComponent(horizontalBarChartType, "HorizontalBarChart");
|
|
53
|
+
var PieChart = createChartComponent(pieChartType, "PieChart");
|
|
54
|
+
var DonutChart = createChartComponent(donutChartType, "DonutChart");
|
|
55
|
+
var ScatterChart = createChartComponent(scatterChartType, "ScatterChart");
|
|
56
|
+
var SparklineChart = createChartComponent(sparklineChartType, "SparklineChart");
|
|
57
|
+
var AreaChart = createChartComponent(areaChartType, "AreaChart");
|
|
58
|
+
var RadarChart = createChartComponent(radarChartType, "RadarChart");
|
|
59
|
+
var BubbleChart = createChartComponent(bubbleChartType, "BubbleChart");
|
|
60
|
+
var CandlestickChart = createChartComponent(candlestickChartType, "CandlestickChart");
|
|
61
|
+
var GaugeChart = createChartComponent(gaugeChartType, "GaugeChart");
|
|
62
|
+
var WaterfallChart = createChartComponent(waterfallChartType, "WaterfallChart");
|
|
63
|
+
var FunnelChart = createChartComponent(funnelChartType, "FunnelChart");
|
|
64
|
+
var HeatmapChart = createChartComponent(heatmapChartType, "HeatmapChart");
|
|
65
|
+
var BoxplotChart = createChartComponent(boxplotChartType, "BoxplotChart");
|
|
66
|
+
var HistogramChart = createChartComponent(histogramChartType, "HistogramChart");
|
|
67
|
+
var TreemapChart = createChartComponent(treemapChartType, "TreemapChart");
|
|
68
|
+
var PolarChart = createChartComponent(polarChartType, "PolarChart");
|
|
69
|
+
var RadialBarChart = createChartComponent(radialBarChartType, "RadialBarChart");
|
|
70
|
+
var LollipopChart = createChartComponent(lollipopChartType, "LollipopChart");
|
|
71
|
+
var BulletChart = createChartComponent(bulletChartType, "BulletChart");
|
|
72
|
+
var DumbbellChart = createChartComponent(dumbbellChartType, "DumbbellChart");
|
|
73
|
+
var CalendarChart = createChartComponent(calendarChartType, "CalendarChart");
|
|
74
|
+
var ComboChart = createChartComponent(comboChartType, "ComboChart");
|
|
75
|
+
var SankeyChart = createChartComponent(sankeyChartType, "SankeyChart");
|
|
76
|
+
var SunburstChart = createChartComponent(sunburstChartType, "SunburstChart");
|
|
77
|
+
var TreeChart = createChartComponent(treeChartType, "TreeChart");
|
|
78
|
+
var GraphChart = createChartComponent(graphChartType, "GraphChart");
|
|
79
|
+
var ParallelChart = createChartComponent(parallelChartType, "ParallelChart");
|
|
80
|
+
var ThemeRiverChart = createChartComponent(themeRiverChartType, "ThemeRiverChart");
|
|
81
|
+
var PictorialBarChart = createChartComponent(pictorialBarChartType, "PictorialBarChart");
|
|
82
|
+
var ChordChart = createChartComponent(chordChartType, "ChordChart");
|
|
83
|
+
var GeoChart = createChartComponent(geoChartType, "GeoChart");
|
|
84
|
+
var LinesChart = createChartComponent(linesChartType, "LinesChart");
|
|
85
|
+
var MatrixChart = createChartComponent(matrixChartType, "MatrixChart");
|
|
86
|
+
var CustomChart = createChartComponent(customChartType, "CustomChart");
|
|
87
|
+
var OHLCChart = createChartComponent(ohlcChartType, "OHLCChart");
|
|
88
|
+
var StepChart = createChartComponent(stepChartType, "StepChart");
|
|
89
|
+
var VolumeChart = createChartComponent(volumeChartType, "VolumeChart");
|
|
90
|
+
var RangeChart = createChartComponent(rangeChartType, "RangeChart");
|
|
91
|
+
var BaselineChart = createChartComponent(baselineChartType, "BaselineChart");
|
|
92
|
+
var KagiChart = createChartComponent(kagiChartType, "KagiChart");
|
|
93
|
+
var RenkoChart = createChartComponent(renkoChartType, "RenkoChart");
|
|
94
|
+
var Chart = forwardRef(
|
|
95
|
+
function Chart2({ type, data, className, style, loading, error, empty, ...options }, fwdRef) {
|
|
96
|
+
const container = useRef(null);
|
|
97
|
+
const instance = useChart(container, type, data, options);
|
|
98
|
+
useImperativeHandle(fwdRef, () => instance.current, [instance]);
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (!instance.current) return;
|
|
101
|
+
if (loading) {
|
|
102
|
+
instance.current.setLoading(true);
|
|
103
|
+
} else if (error) {
|
|
104
|
+
instance.current.setError(typeof error === "string" ? error : void 0);
|
|
105
|
+
} else if (empty) {
|
|
106
|
+
instance.current.setEmpty(typeof empty === "string" ? empty : void 0);
|
|
107
|
+
} else {
|
|
108
|
+
instance.current.setLoading(false);
|
|
109
|
+
}
|
|
110
|
+
}, [loading, error, empty]);
|
|
111
|
+
return /* @__PURE__ */ jsx("div", { ref: container, className, style });
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
export { AreaChart, BarChart, BaselineChart, BoxplotChart, BubbleChart, BulletChart, CalendarChart, CandlestickChart, Chart, ChordChart, ComboChart, CustomChart, DonutChart, DumbbellChart, FunnelChart, GaugeChart, GeoChart, GraphChart, HeatmapChart, HistogramChart, HorizontalBarChart, KagiChart, LineChart, LinesChart, LollipopChart, MatrixChart, OHLCChart, ParallelChart, PictorialBarChart, PieChart, PolarChart, RadarChart, RadialBarChart, RangeChart, RenkoChart, SankeyChart, ScatterChart, SparklineChart, StackedBarChart, StepChart, SunburstChart, ThemeRiverChart, TreeChart, TreemapChart, VolumeChart, WaterfallChart, useChart };
|
|
116
|
+
//# sourceMappingURL=index.js.map
|
|
117
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"names":["Chart"],"mappings":";;;;;;AAyBA,SAAS,QAAA,CACP,GAAA,EACA,SAAA,EACA,IAAA,EACA,OAAA,EACuC;AACvC,EAAA,MAAM,QAAA,GAAW,OAA6B,IAAI,CAAA;AAElD,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,CAAC,IAAI,OAAA,EAAS;AAElB,IAAA,QAAA,CAAS,UAAU,WAAA,CAAY,GAAA,CAAI,OAAA,EAAS,SAAA,EAAW,MAAM,OAAO,CAAA;AAEpE,IAAA,OAAO,MAAM;AACX,MAAA,QAAA,CAAS,SAAS,OAAA,EAAQ;AAC1B,MAAA,QAAA,CAAS,OAAA,GAAU,IAAA;AAAA,IACrB,CAAA;AAAA,EAEF,CAAA,EAAG,CAAC,GAAA,CAAI,OAAO,CAAC,CAAA;AAEhB,EAAA,SAAA,C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AAA,GAAW,QAAQ,MAAS,CAAA;AAAA,MACzE,CAAA,MAAO;AACL,QAAA,QAAA,CAAS,OAAA,CAAQ,WAAW,KAAK,CAAA;AAAA,MACnC;AAAA,IACF,CAAA,EAAG,CAAC,OAAA,EAAS,KAAA,EAAO,KAAK,CAAC,CAAA;AAE1B,IAAA,uBAAO,GAAA,CAAC,KAAA,EAAA,EAAI,GAAA,EAAK,SAAA,EAAW,WAAsB,KAAA,EAAc,CAAA;AAAA,EAClE;AACF","file":"index.js","sourcesContent":["import {\n useRef, useEffect, forwardRef, useImperativeHandle,\n type Ref,\n} from 'react'\nimport {\n createChart,\n lineChartType, barChartType, stackedBarChartType, horizontalBarChartType,\n pieChartType, donutChartType, scatterChartType, sparklineChartType,\n areaChartType, radarChartType, bubbleChartType, candlestickChartType,\n gaugeChartType, waterfallChartType, funnelChartType, heatmapChartType,\n boxplotChartType, histogramChartType, treemapChartType, polarChartType,\n radialBarChartType, lollipopChartType, bulletChartType, dumbbellChartType,\n calendarChartType, comboChartType, sankeyChartType,\n sunburstChartType, treeChartType, graphChartType, parallelChartType,\n themeRiverChartType, pictorialBarChartType, chordChartType,\n geoChartType, linesChartType, matrixChartType, customChartType,\n ohlcChartType, stepChartType, volumeChartType, rangeChartType,\n baselineChartType, kagiChartType, renkoChartType,\n type ChartData, type ChartOptions, type ChartInstance, type ChartTypePlugin,\n} from '@chartts/core'\n\n// ---------------------------------------------------------------------------\n// Shared hook — manages chart lifecycle, data updates, and options\n// ---------------------------------------------------------------------------\n\nfunction useChart(\n ref: React.RefObject<HTMLDivElement | null>,\n chartType: ChartTypePlugin,\n data: ChartData,\n options: ChartOptions,\n): React.RefObject<ChartInstance | null> {\n const instance = useRef<ChartInstance | null>(null)\n\n useEffect(() => {\n if (!ref.current) return\n\n instance.current = createChart(ref.current, chartType, data, options)\n\n return () => {\n instance.current?.destroy()\n instance.current = null\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [ref.current])\n\n useEffect(() => {\n instance.current?.setData(data)\n }, [data])\n\n useEffect(() => {\n instance.current?.setOptions(options)\n }, [options])\n\n return instance\n}\n\n// ---------------------------------------------------------------------------\n// Props\n// ---------------------------------------------------------------------------\n\nexport interface ChartProps extends ChartOptions {\n data: ChartData\n className?: string\n style?: React.CSSProperties\n /** Show loading skeleton instead of chart */\n loading?: boolean\n /** Show error state with optional message */\n error?: string | boolean\n /** Show empty state with optional message */\n empty?: string | boolean\n}\n\n// ---------------------------------------------------------------------------\n// Factory — generates typed chart components from chart type plugins\n// ---------------------------------------------------------------------------\n\nfunction createChartComponent(chartType: ChartTypePlugin, displayName: string) {\n const Component = forwardRef<ChartInstance, ChartProps>(\n function ChartComponent(\n { data, className, style, loading, error, empty, ...options }: ChartProps,\n fwdRef: Ref<ChartInstance>,\n ) {\n const container = useRef<HTMLDivElement | null>(null)\n const instance = useChart(container, chartType, data, options)\n\n useImperativeHandle(fwdRef, () => instance.current!, [instance])\n\n // Handle state props\n useEffect(() => {\n if (!instance.current) return\n if (loading) {\n instance.current.setLoading(true)\n } else if (error) {\n instance.current.setError(typeof error === 'string' ? error : undefined)\n } else if (empty) {\n instance.current.setEmpty(typeof empty === 'string' ? empty : undefined)\n } else {\n instance.current.setLoading(false)\n }\n }, [loading, error, empty])\n\n return <div ref={container} className={className} style={style} />\n },\n )\n Component.displayName = displayName\n return Component\n}\n\n// ---------------------------------------------------------------------------\n// Chart components — one per chart type\n// ---------------------------------------------------------------------------\n\nexport const LineChart = createChartComponent(lineChartType, 'LineChart')\nexport const BarChart = createChartComponent(barChartType, 'BarChart')\nexport const StackedBarChart = createChartComponent(stackedBarChartType, 'StackedBarChart')\nexport const HorizontalBarChart = createChartComponent(horizontalBarChartType, 'HorizontalBarChart')\nexport const PieChart = createChartComponent(pieChartType, 'PieChart')\nexport const DonutChart = createChartComponent(donutChartType, 'DonutChart')\nexport const ScatterChart = createChartComponent(scatterChartType, 'ScatterChart')\nexport const SparklineChart = createChartComponent(sparklineChartType, 'SparklineChart')\nexport const AreaChart = createChartComponent(areaChartType, 'AreaChart')\nexport const RadarChart = createChartComponent(radarChartType, 'RadarChart')\nexport const BubbleChart = createChartComponent(bubbleChartType, 'BubbleChart')\nexport const CandlestickChart = createChartComponent(candlestickChartType, 'CandlestickChart')\nexport const GaugeChart = createChartComponent(gaugeChartType, 'GaugeChart')\nexport const WaterfallChart = createChartComponent(waterfallChartType, 'WaterfallChart')\nexport const FunnelChart = createChartComponent(funnelChartType, 'FunnelChart')\nexport const HeatmapChart = createChartComponent(heatmapChartType, 'HeatmapChart')\nexport const BoxplotChart = createChartComponent(boxplotChartType, 'BoxplotChart')\nexport const HistogramChart = createChartComponent(histogramChartType, 'HistogramChart')\nexport const TreemapChart = createChartComponent(treemapChartType, 'TreemapChart')\nexport const PolarChart = createChartComponent(polarChartType, 'PolarChart')\nexport const RadialBarChart = createChartComponent(radialBarChartType, 'RadialBarChart')\nexport const LollipopChart = createChartComponent(lollipopChartType, 'LollipopChart')\nexport const BulletChart = createChartComponent(bulletChartType, 'BulletChart')\nexport const DumbbellChart = createChartComponent(dumbbellChartType, 'DumbbellChart')\nexport const CalendarChart = createChartComponent(calendarChartType, 'CalendarChart')\nexport const ComboChart = createChartComponent(comboChartType, 'ComboChart')\nexport const SankeyChart = createChartComponent(sankeyChartType, 'SankeyChart')\nexport const SunburstChart = createChartComponent(sunburstChartType, 'SunburstChart')\nexport const TreeChart = createChartComponent(treeChartType, 'TreeChart')\nexport const GraphChart = createChartComponent(graphChartType, 'GraphChart')\nexport const ParallelChart = createChartComponent(parallelChartType, 'ParallelChart')\nexport const ThemeRiverChart = createChartComponent(themeRiverChartType, 'ThemeRiverChart')\nexport const PictorialBarChart = createChartComponent(pictorialBarChartType, 'PictorialBarChart')\nexport const ChordChart = createChartComponent(chordChartType, 'ChordChart')\nexport const GeoChart = createChartComponent(geoChartType, 'GeoChart')\nexport const LinesChart = createChartComponent(linesChartType, 'LinesChart')\nexport const MatrixChart = createChartComponent(matrixChartType, 'MatrixChart')\nexport const CustomChart = createChartComponent(customChartType, 'CustomChart')\nexport const OHLCChart = createChartComponent(ohlcChartType, 'OHLCChart')\nexport const StepChart = createChartComponent(stepChartType, 'StepChart')\nexport const VolumeChart = createChartComponent(volumeChartType, 'VolumeChart')\nexport const RangeChart = createChartComponent(rangeChartType, 'RangeChart')\nexport const BaselineChart = createChartComponent(baselineChartType, 'BaselineChart')\nexport const KagiChart = createChartComponent(kagiChartType, 'KagiChart')\nexport const RenkoChart = createChartComponent(renkoChartType, 'RenkoChart')\n\n// ---------------------------------------------------------------------------\n// Generic Chart — pass any ChartTypePlugin\n// ---------------------------------------------------------------------------\n\nexport interface GenericChartProps extends ChartProps {\n type: ChartTypePlugin\n}\n\nexport const Chart = forwardRef<ChartInstance, GenericChartProps>(\n function Chart(\n { type, data, className, style, loading, error, empty, ...options }: GenericChartProps,\n fwdRef: Ref<ChartInstance>,\n ) {\n const container = useRef<HTMLDivElement | null>(null)\n const instance = useChart(container, type, data, options)\n\n useImperativeHandle(fwdRef, () => instance.current!, [instance])\n\n useEffect(() => {\n if (!instance.current) return\n if (loading) {\n instance.current.setLoading(true)\n } else if (error) {\n instance.current.setError(typeof error === 'string' ? error : undefined)\n } else if (empty) {\n instance.current.setEmpty(typeof empty === 'string' ? empty : undefined)\n } else {\n instance.current.setLoading(false)\n }\n }, [loading, error, empty])\n\n return <div ref={container} className={className} style={style} />\n },\n)\n\n// ---------------------------------------------------------------------------\n// useChart hook for advanced use cases\n// ---------------------------------------------------------------------------\n\nexport { useChart }\n\n// ---------------------------------------------------------------------------\n// Re-exports from core\n// ---------------------------------------------------------------------------\n\nexport {\n // Chart type plugins\n lineChartType, barChartType, stackedBarChartType, horizontalBarChartType,\n pieChartType, donutChartType, scatterChartType, sparklineChartType,\n areaChartType, radarChartType, bubbleChartType, candlestickChartType,\n gaugeChartType, waterfallChartType, funnelChartType, heatmapChartType,\n boxplotChartType, histogramChartType, treemapChartType, polarChartType,\n radialBarChartType, lollipopChartType, bulletChartType, dumbbellChartType,\n calendarChartType, comboChartType, sankeyChartType,\n sunburstChartType, treeChartType, graphChartType, parallelChartType,\n themeRiverChartType, pictorialBarChartType, chordChartType,\n geoChartType, linesChartType, matrixChartType, customChartType,\n ohlcChartType, stepChartType, volumeChartType, rangeChartType,\n baselineChartType, kagiChartType, renkoChartType,\n // Theme\n resolveTheme, applyTheme,\n LIGHT_THEME, DARK_THEME, PALETTE,\n THEME_PRESETS, CORPORATE_THEME, SAAS_THEME, STARTUP_THEME, EDITORIAL_THEME, OCEAN_THEME,\n // Formatters\n formatValue, formatPercent,\n} from '@chartts/core'\nexport type { ChartData, ChartOptions, ChartInstance, ChartTypePlugin, ThemeConfig, Series } from '@chartts/core'\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chartts/react",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "Chartts React components — native, not a wrapper.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"react": ">=18.0.0",
|
|
22
|
+
"react-dom": ">=18.0.0",
|
|
23
|
+
"@chartts/core": "0.1.3"
|
|
24
|
+
},
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/chartts/chartts"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://chartts.com",
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsup",
|
|
33
|
+
"dev": "tsup --watch"
|
|
34
|
+
}
|
|
35
|
+
}
|