react-use-echarts 0.0.3 โ 0.0.4
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 +21 -11
- package/dist/index.d.ts +8 -8
- package/dist/index.es.js +1 -1
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ pnpm add react-use-echarts echarts
|
|
|
31
31
|
## ๐จ Usage
|
|
32
32
|
|
|
33
33
|
```tsx
|
|
34
|
-
import {
|
|
34
|
+
import { useEcharts } from 'react-use-echarts';
|
|
35
35
|
|
|
36
36
|
function MyChart() {
|
|
37
37
|
const options = {
|
|
@@ -48,7 +48,9 @@ function MyChart() {
|
|
|
48
48
|
}]
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
const { chartRef } =
|
|
51
|
+
const { chartRef } = useEcharts({
|
|
52
|
+
option: options
|
|
53
|
+
});
|
|
52
54
|
|
|
53
55
|
return <div ref={chartRef} style={{ width: '100%', height: '400px' }} />;
|
|
54
56
|
}
|
|
@@ -56,25 +58,33 @@ function MyChart() {
|
|
|
56
58
|
|
|
57
59
|
## ๐ API
|
|
58
60
|
|
|
59
|
-
###
|
|
61
|
+
### useEcharts
|
|
60
62
|
|
|
61
63
|
The main hook for using ECharts in React components.
|
|
62
64
|
|
|
63
65
|
```tsx
|
|
64
|
-
const { chartRef,
|
|
66
|
+
const { chartRef, setOption, getInstance } = useEcharts({
|
|
67
|
+
option: EChartsOption; // ECharts options configuration (required)
|
|
68
|
+
theme?: string | object; // ECharts theme name or configuration
|
|
69
|
+
notMerge?: boolean; // Whether to not merge with previous options
|
|
70
|
+
lazyUpdate?: boolean; // Whether to update chart lazily
|
|
71
|
+
showLoading?: boolean; // Whether to display loading animation
|
|
72
|
+
loadingOption?: object; // Loading animation configuration
|
|
73
|
+
onEvents?: { // Event handlers
|
|
74
|
+
[eventName: string]: {
|
|
75
|
+
handler: (params: any) => void;
|
|
76
|
+
query?: string | object;
|
|
77
|
+
context?: object;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
65
81
|
```
|
|
66
82
|
|
|
67
|
-
#### Parameters
|
|
68
|
-
|
|
69
|
-
- `options` (required): ECharts options configuration
|
|
70
|
-
- `theme` (optional): ECharts theme name or configuration
|
|
71
|
-
- `opts` (optional): ECharts initialization options
|
|
72
|
-
|
|
73
83
|
#### Returns
|
|
74
84
|
|
|
75
85
|
- `chartRef`: Ref object to attach to the chart container
|
|
76
|
-
- `instance`: ECharts instance (available after component mounts)
|
|
77
86
|
- `setOption`: Function to update chart options
|
|
87
|
+
- `getInstance`: Function to get the ECharts instance (available after component mounts)
|
|
78
88
|
|
|
79
89
|
## ๐ค Contributing
|
|
80
90
|
|
package/dist/index.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ export declare type Theme = string | object | null;
|
|
|
70
70
|
*
|
|
71
71
|
* @example
|
|
72
72
|
* ```typescript
|
|
73
|
-
* const { chartRef, setOption, getInstance } =
|
|
73
|
+
* const { chartRef, setOption, getInstance } = useEcharts({
|
|
74
74
|
* option: {
|
|
75
75
|
* xAxis: { type: 'category', data: ['A', 'B', 'C'] },
|
|
76
76
|
* yAxis: { type: 'value' },
|
|
@@ -86,13 +86,13 @@ export declare type Theme = string | object | null;
|
|
|
86
86
|
* return <div ref={chartRef} style={{ width: '100%', height: '400px' }} />;
|
|
87
87
|
* ```
|
|
88
88
|
*/
|
|
89
|
-
export declare const
|
|
89
|
+
export declare const useEcharts: ({ option, theme, notMerge, lazyUpdate, showLoading, loadingOption, onEvents, }: UseEchartsOptions) => UseEchartsReturn;
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
|
-
* Configuration options for
|
|
93
|
-
*
|
|
92
|
+
* Configuration options for useEcharts hook
|
|
93
|
+
* useEcharts hook ็้
็ฝฎ้้กน
|
|
94
94
|
*/
|
|
95
|
-
export declare interface
|
|
95
|
+
export declare interface UseEchartsOptions {
|
|
96
96
|
/**
|
|
97
97
|
* ECharts configuration options
|
|
98
98
|
* ECharts ็้
็ฝฎ้กน
|
|
@@ -134,10 +134,10 @@ export declare interface UseEChartsOptions {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
/**
|
|
137
|
-
* Return type for
|
|
138
|
-
*
|
|
137
|
+
* Return type for useEcharts hook
|
|
138
|
+
* useEcharts hook ็่ฟๅ็ฑปๅ
|
|
139
139
|
*/
|
|
140
|
-
export declare interface
|
|
140
|
+
export declare interface UseEchartsReturn {
|
|
141
141
|
/**
|
|
142
142
|
* Reference to the chart container element
|
|
143
143
|
* ๅพ่กจๅฎนๅจๅ
็ด ็ๅผ็จ
|
package/dist/index.es.js
CHANGED
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(n,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("react"),require("echarts")):typeof define=="function"&&define.amd?define(["exports","react","echarts"],t):(n=typeof globalThis<"u"?globalThis:n||self,t(n["react-use-echarts"]={},n.React,n.echarts))})(this,function(n,t,y){"use strict";function m(c){const f=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const u in c)if(u!=="default"){const o=Object.getOwnPropertyDescriptor(c,u);Object.defineProperty(f,u,o.get?o:{enumerable:!0,get:()=>c[u]})}}return f.default=c,Object.freeze(f)}const g=m(y),w=({option:c,theme:f,notMerge:u=!1,lazyUpdate:o=!1,showLoading:h=!1,loadingOption:p,onEvents:a})=>{const l=t.useRef(null),e=t.useRef(),E=t.useCallback(()=>e.current,[]),R=t.useCallback((r,s)=>{var i;(i=e.current)==null||i.setOption(r,s)},[]);return t.useEffect(()=>{if(l.current)return e.current||(e.current=g.init(l.current,f)),a&&e.current&&Object.entries(a).forEach(([r,s])=>{var O,j;const{handler:i,query:d,context:b}=s;d?(O=e.current)==null||O.on(r,d,i,b):(j=e.current)==null||j.on(r,i,b)}),()=>{e.current&&(a&&Object.entries(a).forEach(([r,s])=>{var d;const{handler:i}=s;(d=e.current)==null||d.off(r,i)}),e.current.dispose(),e.current=void 0)}},[f,a]),t.useEffect(()=>{e.current&&(h?e.current.showLoading(p):e.current.hideLoading(),e.current.setOption(c,{notMerge:u,lazyUpdate:o}))},[c,u,o,h,p]),t.useEffect(()=>{const r=()=>{var s;(s=e.current)==null||s.resize()};return window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r)}},[]),{chartRef:l,setOption:R,getInstance:E}};n.
|
|
1
|
+
(function(n,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("react"),require("echarts")):typeof define=="function"&&define.amd?define(["exports","react","echarts"],t):(n=typeof globalThis<"u"?globalThis:n||self,t(n["react-use-echarts"]={},n.React,n.echarts))})(this,function(n,t,y){"use strict";function m(c){const f=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const u in c)if(u!=="default"){const o=Object.getOwnPropertyDescriptor(c,u);Object.defineProperty(f,u,o.get?o:{enumerable:!0,get:()=>c[u]})}}return f.default=c,Object.freeze(f)}const g=m(y),w=({option:c,theme:f,notMerge:u=!1,lazyUpdate:o=!1,showLoading:h=!1,loadingOption:p,onEvents:a})=>{const l=t.useRef(null),e=t.useRef(),E=t.useCallback(()=>e.current,[]),R=t.useCallback((r,s)=>{var i;(i=e.current)==null||i.setOption(r,s)},[]);return t.useEffect(()=>{if(l.current)return e.current||(e.current=g.init(l.current,f)),a&&e.current&&Object.entries(a).forEach(([r,s])=>{var O,j;const{handler:i,query:d,context:b}=s;d?(O=e.current)==null||O.on(r,d,i,b):(j=e.current)==null||j.on(r,i,b)}),()=>{e.current&&(a&&Object.entries(a).forEach(([r,s])=>{var d;const{handler:i}=s;(d=e.current)==null||d.off(r,i)}),e.current.dispose(),e.current=void 0)}},[f,a]),t.useEffect(()=>{e.current&&(h?e.current.showLoading(p):e.current.hideLoading(),e.current.setOption(c,{notMerge:u,lazyUpdate:o}))},[c,u,o,h,p]),t.useEffect(()=>{const r=()=>{var s;(s=e.current)==null||s.resize()};return window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r)}},[]),{chartRef:l,setOption:R,getInstance:E}};n.useEcharts=w,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
|