echarts-for-react 3.0.5 → 3.0.7
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/esm/core.d.ts +9 -1
- package/esm/core.js +20 -14
- package/esm/core.js.map +1 -1
- package/lib/core.d.ts +9 -1
- package/lib/core.js +20 -14
- package/lib/core.js.map +1 -1
- package/package.json +4 -1
- package/src/.umi/core/devScripts.ts +53 -0
- package/src/.umi/core/history.ts +21 -0
- package/src/.umi/core/plugin.ts +8 -0
- package/src/.umi/core/pluginConfig.d.ts +300 -0
- package/src/.umi/core/pluginRegister.ts +5 -0
- package/src/.umi/core/polyfill.ts +4 -0
- package/src/.umi/core/routes.ts +389 -0
- package/src/.umi/core/umiExports.ts +3 -0
- package/src/.umi/dumi/apis.json +1 -0
- package/src/.umi/dumi/config.json +129 -0
- package/src/.umi/dumi/demos/index.ts +5469 -0
- package/src/.umi/dumi/layout.tsx +8 -0
- package/src/.umi/umi.ts +58 -0
- package/src/.umi-production/core/history.ts +21 -0
- package/src/.umi-production/core/plugin.ts +8 -0
- package/src/.umi-production/core/pluginConfig.d.ts +300 -0
- package/src/.umi-production/core/pluginRegister.ts +5 -0
- package/src/.umi-production/core/polyfill.ts +4 -0
- package/src/.umi-production/core/routes.ts +389 -0
- package/src/.umi-production/core/umiExports.ts +3 -0
- package/src/.umi-production/dumi/apis.json +1 -0
- package/src/.umi-production/dumi/config.json +129 -0
- package/src/.umi-production/dumi/demos/index.ts +5469 -0
- package/src/.umi-production/dumi/layout.tsx +8 -0
- package/src/.umi-production/umi.ts +58 -0
- package/src/core.tsx +26 -13
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import config from '@@/dumi/config';
|
|
4
|
+
import demos from '@@/dumi/demos';
|
|
5
|
+
import apis from '@@/dumi/apis';
|
|
6
|
+
import Layout from '/Users/xiaowei/Documents/code/antv/echarts-for-react/node_modules/_@umijs_preset-dumi@1.1.54@@umijs/preset-dumi/lib/theme/layout';
|
|
7
|
+
|
|
8
|
+
export default (props) => <Layout {...props} config={config} demos={demos} apis={apis} />;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import './core/polyfill';
|
|
3
|
+
|
|
4
|
+
import { plugin } from './core/plugin';
|
|
5
|
+
import './core/pluginRegister';
|
|
6
|
+
import { createHistory } from './core/history';
|
|
7
|
+
import { ApplyPluginsType } from '/Users/xiaowei/Documents/code/antv/echarts-for-react/node_modules/_@umijs_runtime@3.5.43@@umijs/runtime';
|
|
8
|
+
import { renderClient } from '/Users/xiaowei/Documents/code/antv/echarts-for-react/node_modules/_@umijs_renderer-react@3.5.43@@umijs/renderer-react/dist/index.js';
|
|
9
|
+
import { getRoutes } from './core/routes';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
const getClientRender = (args: { hot?: boolean; routes?: any[] } = {}) => plugin.applyPlugins({
|
|
15
|
+
key: 'render',
|
|
16
|
+
type: ApplyPluginsType.compose,
|
|
17
|
+
initialValue: () => {
|
|
18
|
+
const opts = plugin.applyPlugins({
|
|
19
|
+
key: 'modifyClientRenderOpts',
|
|
20
|
+
type: ApplyPluginsType.modify,
|
|
21
|
+
initialValue: {
|
|
22
|
+
routes: args.routes || getRoutes(),
|
|
23
|
+
plugin,
|
|
24
|
+
history: createHistory(args.hot),
|
|
25
|
+
isServer: process.env.__IS_SERVER,
|
|
26
|
+
rootElement: 'root',
|
|
27
|
+
defaultTitle: ``,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
return renderClient(opts);
|
|
31
|
+
},
|
|
32
|
+
args,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const clientRender = getClientRender();
|
|
36
|
+
export default clientRender();
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
window.g_umi = {
|
|
40
|
+
version: '3.5.43',
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
// hot module replacement
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
if (module.hot) {
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
module.hot.accept('./core/routes', () => {
|
|
49
|
+
const ret = require('./core/routes');
|
|
50
|
+
if (ret.then) {
|
|
51
|
+
ret.then(({ getRoutes }) => {
|
|
52
|
+
getClientRender({ hot: true, routes: getRoutes() })();
|
|
53
|
+
});
|
|
54
|
+
} else {
|
|
55
|
+
getClientRender({ hot: true, routes: ret.getRoutes() })();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
package/src/core.tsx
CHANGED
|
@@ -26,12 +26,18 @@ export default class EChartsReactCore extends PureComponent<EChartsReactProps> {
|
|
|
26
26
|
*/
|
|
27
27
|
protected echarts: any;
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Currently attached ECharts event listeners
|
|
31
|
+
*/
|
|
32
|
+
private eventHandlerRefs: Record<string, Function>;
|
|
33
|
+
|
|
29
34
|
constructor(props: EChartsReactProps) {
|
|
30
35
|
super(props);
|
|
31
36
|
|
|
32
37
|
this.echarts = props.echarts;
|
|
33
38
|
this.ele = null;
|
|
34
39
|
this.isInitialResize = true;
|
|
40
|
+
this.eventHandlerRefs = {};
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
componentDidMount() {
|
|
@@ -62,7 +68,7 @@ export default class EChartsReactCore extends PureComponent<EChartsReactProps> {
|
|
|
62
68
|
// 修改 onEvent 的时候先移除历史事件再添加
|
|
63
69
|
const echartsInstance = this.getEchartsInstance();
|
|
64
70
|
if (!isEqual(prevProps.onEvents, this.props.onEvents)) {
|
|
65
|
-
this.
|
|
71
|
+
this.unbindEvents(echartsInstance);
|
|
66
72
|
this.bindEvents(echartsInstance, this.props.onEvents);
|
|
67
73
|
}
|
|
68
74
|
|
|
@@ -163,15 +169,21 @@ export default class EChartsReactCore extends PureComponent<EChartsReactProps> {
|
|
|
163
169
|
|
|
164
170
|
// bind the events
|
|
165
171
|
private bindEvents(instance, events: EChartsReactProps['onEvents']) {
|
|
166
|
-
|
|
172
|
+
const _bindEvent = (eventName: string, func: Function) => {
|
|
167
173
|
// ignore the event config which not satisfy
|
|
168
174
|
if (isString(eventName) && isFunction(func)) {
|
|
169
175
|
// binding event
|
|
170
|
-
|
|
176
|
+
const handler = (param) => {
|
|
171
177
|
func(param, instance);
|
|
172
|
-
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
instance.on(eventName, handler);
|
|
181
|
+
|
|
182
|
+
// Store currently bound event handlers. This way we can unbind them
|
|
183
|
+
// on next component update, before binding the new handlers.
|
|
184
|
+
this.eventHandlerRefs[eventName] = handler;
|
|
173
185
|
}
|
|
174
|
-
}
|
|
186
|
+
};
|
|
175
187
|
|
|
176
188
|
// loop and bind
|
|
177
189
|
for (const eventName in events) {
|
|
@@ -181,15 +193,16 @@ export default class EChartsReactCore extends PureComponent<EChartsReactProps> {
|
|
|
181
193
|
}
|
|
182
194
|
}
|
|
183
195
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
196
|
+
/**
|
|
197
|
+
* Unbind all currently bound event handlers. Importantly, this does not
|
|
198
|
+
* unbind the `"finished"` event that is used for chart initialization.
|
|
199
|
+
*/
|
|
200
|
+
private unbindEvents(instance: EChartsInstance) {
|
|
201
|
+
for (const [eventName, listener] of Object.entries(this.eventHandlerRefs)) {
|
|
202
|
+
instance.off(eventName, listener);
|
|
192
203
|
}
|
|
204
|
+
|
|
205
|
+
this.eventHandlerRefs = {};
|
|
193
206
|
}
|
|
194
207
|
|
|
195
208
|
/**
|