echarts-for-react 1.4.3 → 1.4.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 CHANGED
@@ -148,12 +148,12 @@ for example:
148
148
 
149
149
  ```js
150
150
  // render the echarts component below with rel
151
- <ReactEcharts ref='echarts_react'
151
+ <ReactEcharts ref={(e) => { this.echarts_react = e; }}
152
152
  option={this.getOption()} />
153
153
 
154
- // then get the `ReactEcharts` use this.refs.echarts_react
154
+ // then get the `ReactEcharts` use this.echarts_react
155
155
 
156
- let echarts_instance = this.refs.echarts_react.getEchartsInstance();
156
+ let echarts_instance = this.echarts_react.getEchartsInstance();
157
157
  // then you can use any API of echarts.
158
158
  let base64 = echarts_instance.getDataURL();
159
159
  ```
package/lib/core.js CHANGED
@@ -35,7 +35,7 @@ var ReactEcharts = function (_React$Component) {
35
35
  var _this = _possibleConstructorReturn(this, (ReactEcharts.__proto__ || Object.getPrototypeOf(ReactEcharts)).call(this, props));
36
36
 
37
37
  _this.getEchartsInstance = function () {
38
- return _this.props.echarts.getInstanceByDom(_this.echartsElement) || _this.props.echarts.init(_this.echartsElement, _this.props.theme);
38
+ return _this.echartsInstance.getInstanceByDom(_this.echartsElement) || _this.echartsInstance.init(_this.echartsElement, _this.props.theme);
39
39
  };
40
40
 
41
41
  _this.bindEvents = function (instance, events) {
@@ -68,6 +68,7 @@ var ReactEcharts = function (_React$Component) {
68
68
  return echartObj;
69
69
  };
70
70
 
71
+ _this.echartsInstance = _this.props.echarts; // the echarts object.
71
72
  _this.echartsElement = null; // echarts div element
72
73
  return _this;
73
74
  }
@@ -110,7 +111,7 @@ var ReactEcharts = function (_React$Component) {
110
111
  if (typeof _elementResizeEvent2['default'].unbind === 'function') {
111
112
  _elementResizeEvent2['default'].unbind(this.echartsElement);
112
113
  }
113
- this.props.echarts.dispose(this.echartsElement);
114
+ this.echartsInstance.dispose(this.echartsElement);
114
115
  }
115
116
  }
116
117
  // return the echart object
@@ -161,6 +162,7 @@ ReactEcharts.propTypes = {
161
162
  };
162
163
 
163
164
  ReactEcharts.defaultProps = {
165
+ echarts: {},
164
166
  notMerge: false,
165
167
  lazyUpdate: false,
166
168
  style: { height: '300px' },
package/lib/index.js CHANGED
@@ -4,12 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
8
-
9
- var _react = require('react');
10
-
11
- var _react2 = _interopRequireDefault(_react);
12
-
13
7
  var _echarts = require('echarts');
14
8
 
15
9
  var _echarts2 = _interopRequireDefault(_echarts);
@@ -20,8 +14,26 @@ var _core2 = _interopRequireDefault(_core);
20
14
 
21
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
22
16
 
23
- var Chart = function Chart(props) {
24
- return _react2['default'].createElement(_core2['default'], _extends({}, props, { echarts: _echarts2['default'] }));
25
- };
17
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
+
19
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
20
+
21
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
22
+
23
+ // export the Component the echarts Object.
24
+ var EchartsReact = function (_Core) {
25
+ _inherits(EchartsReact, _Core);
26
+
27
+ function EchartsReact(props) {
28
+ _classCallCheck(this, EchartsReact);
29
+
30
+ var _this = _possibleConstructorReturn(this, (EchartsReact.__proto__ || Object.getPrototypeOf(EchartsReact)).call(this, props));
31
+
32
+ _this.echartsInstance = _echarts2['default'];
33
+ return _this;
34
+ }
35
+
36
+ return EchartsReact;
37
+ }(_core2['default']);
26
38
 
27
- exports['default'] = Chart;
39
+ exports['default'] = EchartsReact;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "echarts-for-react",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
4
4
  "description": "baidu Echarts(v3.0) components for react",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -69,6 +69,7 @@
69
69
  "eslint-plugin-jsx-a11y": "^3.0.2 || ^4.0.0",
70
70
  "eslint-plugin-react": "^6.9.0",
71
71
  "file-loader": "~0.8.4",
72
+ "immutability-util": "^0.0.1",
72
73
  "jest": "^19.0.2",
73
74
  "jsx-loader": "~0.13.2",
74
75
  "prop-types": "^15.0.0",
package/src/core.js CHANGED
@@ -3,8 +3,9 @@ import PropTypes from 'prop-types';
3
3
  import elementResizeEvent from 'element-resize-event';
4
4
 
5
5
  export default class ReactEcharts extends React.Component {
6
- constructor(props) {
6
+ constructor(props) {
7
7
  super(props);
8
+ this.echartsInstance = this.props.echarts; // the echarts object.
8
9
  this.echartsElement = null; // echarts div element
9
10
  }
10
11
 
@@ -36,12 +37,12 @@ export default class ReactEcharts extends React.Component {
36
37
  if (typeof elementResizeEvent.unbind === 'function') {
37
38
  elementResizeEvent.unbind(this.echartsElement);
38
39
  }
39
- this.props.echarts.dispose(this.echartsElement);
40
+ this.echartsInstance.dispose(this.echartsElement);
40
41
  }
41
42
  }
42
43
  // return the echart object
43
- getEchartsInstance = () => this.props.echarts.getInstanceByDom(this.echartsElement) ||
44
- this.props.echarts.init(this.echartsElement, this.props.theme);
44
+ getEchartsInstance = () => this.echartsInstance.getInstanceByDom(this.echartsElement) ||
45
+ this.echartsInstance.init(this.echartsElement, this.props.theme);
45
46
 
46
47
  // bind the events
47
48
  bindEvents = (instance, events) => {
@@ -106,6 +107,7 @@ ReactEcharts.propTypes = {
106
107
  };
107
108
 
108
109
  ReactEcharts.defaultProps = {
110
+ echarts: {},
109
111
  notMerge: false,
110
112
  lazyUpdate: false,
111
113
  style: {height: '300px'},
package/src/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import React from 'react';
2
1
  import echarts from 'echarts';
3
-
4
2
  import Core from './core';
5
3
 
6
- const Chart = props => (
7
- <Core {...props} echarts={echarts} />
8
- );
9
-
10
- export default Chart;
4
+ // export the Component the echarts Object.
5
+ export default class EchartsReact extends Core {
6
+ constructor(props) {
7
+ super(props);
8
+ this.echartsInstance = echarts;
9
+ }
10
+ }