echarts-for-react 2.0.15-beta.1 → 2.0.16
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 +26 -1
- package/lib/core.js +6 -6
- package/lib/index.d.ts +67 -4
- package/package.json +2 -2
- package/src/core.jsx +6 -6
package/README.md
CHANGED
|
@@ -34,6 +34,28 @@ npm start
|
|
|
34
34
|
|
|
35
35
|
then open [http://127.0.0.1:8080/](http://127.0.0.1:8080/) in your browser. or see [http://git.hust.cc/echarts-for-react/](http://git.hust.cc/echarts-for-react/)
|
|
36
36
|
|
|
37
|
+
## GL
|
|
38
|
+
|
|
39
|
+
Install and import [`echarts-gl`](https://www.npmjs.com/package/echarts-gl) module when you want to create a [GL instance](https://www.echartsjs.com/examples/zh/index.html#chart-type-globe)
|
|
40
|
+
|
|
41
|
+
- **`Install`**
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
npm install --save echarts-gl
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
- **`Import`**
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
import 'echarts-gl'
|
|
51
|
+
import ReactEcharts from "echarts-for-react";
|
|
52
|
+
|
|
53
|
+
<ReactEcharts
|
|
54
|
+
option={GL_OPTION}
|
|
55
|
+
/>
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
|
|
37
59
|
|
|
38
60
|
# 2. usage
|
|
39
61
|
|
|
@@ -135,7 +157,6 @@ import 'echarts/lib/component/title';
|
|
|
135
157
|
opts={} />
|
|
136
158
|
```
|
|
137
159
|
|
|
138
|
-
|
|
139
160
|
# 3. component props
|
|
140
161
|
|
|
141
162
|
- **`option`** (required, object)
|
|
@@ -266,6 +287,10 @@ Use the props `opts` of component with `renderer = 'svg'`. For example:
|
|
|
266
287
|
/>
|
|
267
288
|
```
|
|
268
289
|
|
|
290
|
+
- How to resolve Error `Component series.scatter3D not exists. Load it first.`
|
|
291
|
+
|
|
292
|
+
[Install and import `echarts-gl` first](#GL)
|
|
293
|
+
|
|
269
294
|
|
|
270
295
|
# 6. LICENSE
|
|
271
296
|
|
package/lib/core.js
CHANGED
|
@@ -130,10 +130,15 @@ var EchartsReactCore = function (_Component) {
|
|
|
130
130
|
}, {
|
|
131
131
|
key: 'componentDidUpdate',
|
|
132
132
|
value: function componentDidUpdate(prevProps) {
|
|
133
|
+
// 判断是否需要 setOption,由开发者自己来确定。默认为 true
|
|
134
|
+
if (typeof this.props.shouldSetOption === 'function' && !this.props.shouldSetOption(prevProps, this.props)) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
133
138
|
// 以下属性修改的时候,需要 dispose 之后再新建
|
|
134
139
|
// 1. 切换 theme 的时候
|
|
135
140
|
// 2. 修改 opts 的时候
|
|
136
|
-
// 3. 修改 onEvents
|
|
141
|
+
// 3. 修改 onEvents 的时候,这样可以取消所有之前绑定的事件 issue #151
|
|
137
142
|
if (!(0, _fastDeepEqual2['default'])(prevProps.theme, this.props.theme) || !(0, _fastDeepEqual2['default'])(prevProps.opts, this.props.opts) || !(0, _fastDeepEqual2['default'])(prevProps.onEvents, this.props.onEvents)) {
|
|
138
143
|
this.dispose();
|
|
139
144
|
|
|
@@ -147,11 +152,6 @@ var EchartsReactCore = function (_Component) {
|
|
|
147
152
|
return;
|
|
148
153
|
}
|
|
149
154
|
|
|
150
|
-
// 判断是否需要 setOption,由开发者自己来确定。默认为 true
|
|
151
|
-
if (typeof this.props.shouldSetOption === 'function' && !this.props.shouldSetOption(prevProps, this.props)) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
155
|
var echartObj = this.renderEchartDom();
|
|
156
156
|
// 样式修改的时候,可能会导致大小变化,所以触发一下 resize
|
|
157
157
|
if (!(0, _fastDeepEqual2['default'])(prevProps.style, this.props.style) || !(0, _fastDeepEqual2['default'])(prevProps.className, this.props.className)) {
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
+
import { EChartOption, EChartsLoadingOption, ECharts } from 'echarts';
|
|
4
5
|
|
|
5
6
|
type Func = (...args: any[]) => any;
|
|
6
7
|
|
|
@@ -21,18 +22,80 @@ interface optsMap {
|
|
|
21
22
|
|
|
22
23
|
// Index
|
|
23
24
|
export interface ReactEchartsPropsTypes {
|
|
24
|
-
|
|
25
|
+
/**
|
|
26
|
+
* the echarts option config
|
|
27
|
+
* @see http://echarts.baidu.com/option.html#title
|
|
28
|
+
*/
|
|
29
|
+
option: EChartOption;
|
|
30
|
+
/**
|
|
31
|
+
* when `setOption`, not merge the data.
|
|
32
|
+
* @default false
|
|
33
|
+
* @see http://echarts.baidu.com/api.html#echartsInstance.setOption
|
|
34
|
+
*/
|
|
25
35
|
notMerge?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* when `setOption`, lazy update the data.
|
|
38
|
+
* @default false
|
|
39
|
+
* @see http://echarts.baidu.com/api.html#echartsInstance.setOption
|
|
40
|
+
*/
|
|
26
41
|
lazyUpdate?: boolean;
|
|
27
|
-
|
|
42
|
+
/**
|
|
43
|
+
* the `style` of echarts div.
|
|
44
|
+
* @default {height: '300px'}
|
|
45
|
+
*/
|
|
46
|
+
style?: React.CSSProperties;
|
|
47
|
+
/**
|
|
48
|
+
* the `class` of echarts div. you can setting the css style of charts by class name.
|
|
49
|
+
*/
|
|
28
50
|
className?: string;
|
|
51
|
+
/**
|
|
52
|
+
* the `theme` of echarts. should `registerTheme` before use it.
|
|
53
|
+
* @see https://github.com/ecomfe/echarts/blob/master/theme/dark.js)
|
|
54
|
+
* @example
|
|
55
|
+
* ```
|
|
56
|
+
// register theme object
|
|
57
|
+
echarts.registerTheme('my_theme', { backgroundColor: '#f4cccc' });
|
|
58
|
+
// render the echarts use option `theme`
|
|
59
|
+
<ReactEcharts option={this.getOption()} theme='my_theme' />
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
29
62
|
theme?: string | null | ObjectMap;
|
|
63
|
+
/**
|
|
64
|
+
* when the chart is ready, will callback the function with the `echarts object` as it's paramter.
|
|
65
|
+
*/
|
|
30
66
|
onChartReady?: Func;
|
|
67
|
+
/**
|
|
68
|
+
* when the chart is rendering, show the loading mask.
|
|
69
|
+
*/
|
|
31
70
|
showLoading?: boolean;
|
|
32
|
-
|
|
71
|
+
/**
|
|
72
|
+
* the echarts loading option config.
|
|
73
|
+
* @see http://echarts.baidu.com/api.html#echartsInstance.showLoading
|
|
74
|
+
*/
|
|
75
|
+
loadingOption?: EChartsLoadingOption;
|
|
76
|
+
/**
|
|
77
|
+
* binding the echarts event, will callback with the `echarts event object`, and the `echart object` as it's paramters.
|
|
78
|
+
* @example
|
|
79
|
+
* ```
|
|
80
|
+
let onEvents = {
|
|
81
|
+
'click': this.onChartClick,
|
|
82
|
+
'legendselectchanged': this.onChartLegendselectchanged
|
|
83
|
+
}
|
|
84
|
+
<ReactEcharts onEvents={onEvents} />
|
|
85
|
+
* ```
|
|
86
|
+
* @see: http://echarts.baidu.com/api.html#events
|
|
87
|
+
*/
|
|
33
88
|
onEvents?: EventMap;
|
|
89
|
+
/**
|
|
90
|
+
* the `opts` of echarts. will be used when initial echarts instance by `echarts.init`.
|
|
91
|
+
* @see http://echarts.baidu.com/api.html#echarts.init
|
|
92
|
+
*/
|
|
34
93
|
opts?: optsMap;
|
|
35
94
|
shouldSetOption?: Func;
|
|
36
95
|
}
|
|
37
96
|
|
|
38
|
-
|
|
97
|
+
declare class ReactEcharts extends React.Component<ReactEchartsPropsTypes, any>{
|
|
98
|
+
getEchartsInstance(): ECharts;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export default ReactEcharts;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "echarts-for-react",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.16",
|
|
4
4
|
"description": "baidu Echarts(v3.x & v4.x) components for react.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
90
|
"fast-deep-equal": "^2.0.1",
|
|
91
|
-
"size-sensor": "^0.
|
|
91
|
+
"size-sensor": "^1.0.0"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
94
|
"react": ">=0.13.2 || ^0.14 || ^15.0.0 || >=16.0.0",
|
package/src/core.jsx
CHANGED
|
@@ -18,10 +18,15 @@ export default class EchartsReactCore extends Component {
|
|
|
18
18
|
|
|
19
19
|
// update
|
|
20
20
|
componentDidUpdate(prevProps) {
|
|
21
|
+
// 判断是否需要 setOption,由开发者自己来确定。默认为 true
|
|
22
|
+
if (typeof this.props.shouldSetOption === 'function' && !this.props.shouldSetOption(prevProps, this.props)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
21
26
|
// 以下属性修改的时候,需要 dispose 之后再新建
|
|
22
27
|
// 1. 切换 theme 的时候
|
|
23
28
|
// 2. 修改 opts 的时候
|
|
24
|
-
// 3. 修改 onEvents
|
|
29
|
+
// 3. 修改 onEvents 的时候,这样可以取消所有之前绑定的事件 issue #151
|
|
25
30
|
if (
|
|
26
31
|
!isEqual(prevProps.theme, this.props.theme) ||
|
|
27
32
|
!isEqual(prevProps.opts, this.props.opts) ||
|
|
@@ -39,11 +44,6 @@ export default class EchartsReactCore extends Component {
|
|
|
39
44
|
return;
|
|
40
45
|
}
|
|
41
46
|
|
|
42
|
-
// 判断是否需要 setOption,由开发者自己来确定。默认为 true
|
|
43
|
-
if (typeof this.props.shouldSetOption === 'function' && !this.props.shouldSetOption(prevProps, this.props)) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
47
|
const echartObj = this.renderEchartDom();
|
|
48
48
|
// 样式修改的时候,可能会导致大小变化,所以触发一下 resize
|
|
49
49
|
if (!isEqual(prevProps.style, this.props.style) || !isEqual(prevProps.className, this.props.className)) {
|