@revolist/react-charts 4.0.2-rc → 4.0.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/README.md +10 -3
- package/dist/index.js +15 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -53,7 +53,10 @@ Define your chart configuration:
|
|
|
53
53
|
```ts
|
|
54
54
|
const options = {
|
|
55
55
|
chartType: 'line',
|
|
56
|
-
data: [
|
|
56
|
+
data: [
|
|
57
|
+
{ month: 'Jan', revenue: 120 },
|
|
58
|
+
{ month: 'Feb', revenue: 180 },
|
|
59
|
+
],
|
|
57
60
|
mapping: {
|
|
58
61
|
category: { field: 'month' },
|
|
59
62
|
series: [{ field: 'revenue', label: 'Revenue' }],
|
|
@@ -64,8 +67,12 @@ const options = {
|
|
|
64
67
|
```tsx
|
|
65
68
|
import { RevoChart, type ChartComponentOptions } from '@revolist/react-charts';
|
|
66
69
|
// Use the options above in your component:
|
|
67
|
-
<RevoChart
|
|
68
|
-
|
|
70
|
+
<RevoChart
|
|
71
|
+
options={options}
|
|
72
|
+
onReady={(chart) => console.log(chart.model)}
|
|
73
|
+
style={{ height: 400 }}
|
|
74
|
+
className="sales-chart"
|
|
75
|
+
/>;
|
|
69
76
|
```
|
|
70
77
|
|
|
71
78
|
## Updates and lifecycle
|
package/dist/index.js
CHANGED
|
@@ -8,18 +8,28 @@ export function RevoChart({ options, onReady, serverRender, style, ...attributes
|
|
|
8
8
|
const initial = useRef(serverRender);
|
|
9
9
|
const markup = useRef(serverRender ? { __html: serverRender.svg } : undefined);
|
|
10
10
|
// Update callbacks only after commit; abandoned concurrent renders stay invisible.
|
|
11
|
-
useEffect(() => { ready.current = onReady; }, [onReady]);
|
|
12
11
|
useEffect(() => {
|
|
13
|
-
|
|
12
|
+
ready.current = onReady;
|
|
13
|
+
}, [onReady]);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const instance = createChartComponentController(host.current, (chart) => ready.current?.(chart), !!initial.current);
|
|
14
16
|
controller.current = instance;
|
|
15
17
|
return () => {
|
|
16
18
|
instance.destroy();
|
|
17
19
|
controller.current = undefined;
|
|
18
20
|
};
|
|
19
21
|
}, []);
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
void controller.current?.setOptions(options);
|
|
24
|
+
}, [options]);
|
|
25
|
+
return createElement('div', {
|
|
26
|
+
...attributes,
|
|
27
|
+
ref: host,
|
|
22
28
|
...(markup.current ? { dangerouslySetInnerHTML: markup.current } : {}),
|
|
23
|
-
style: {
|
|
29
|
+
style: {
|
|
30
|
+
width: '100%',
|
|
31
|
+
height: `${initial.current?.height ?? 300}px`,
|
|
32
|
+
...style,
|
|
33
|
+
},
|
|
24
34
|
});
|
|
25
35
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revolist/react-charts",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"description": "React components for RevoGrid Charts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Commercial",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@revolist/charts": "4.0.
|
|
21
|
+
"@revolist/charts": "4.0.3"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"react": "^19.2.0",
|