diff --git a/.babelrc b/.babelrc index 749c081..56131b9 100644 --- a/.babelrc +++ b/.babelrc @@ -1,5 +1,6 @@ { "presets": ["react", "es2015"], + "plugins": ["transform-es3-member-expression-literals", "transform-es3-property-literals"], "env": { "development": { } diff --git a/lib/echarts-for-react.js b/lib/echarts-for-react.js index b512b29..8c38a47 100644 --- a/lib/echarts-for-react.js +++ b/lib/echarts-for-react.js @@ -16,19 +16,19 @@ var _elementResizeEvent = require('element-resize-event'); var _elementResizeEvent2 = _interopRequireDefault(_elementResizeEvent); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } -var ReactEcharts = _react2.default.createClass({ +var ReactEcharts = _react2['default'].createClass({ displayName: 'ReactEcharts', propTypes: { - option: _react2.default.PropTypes.object.isRequired, - style: _react2.default.PropTypes.object, - className: _react2.default.PropTypes.string, - theme: _react2.default.PropTypes.string, - onChartReady: _react2.default.PropTypes.func, - showLoading: _react2.default.PropTypes.bool, - onEvents: _react2.default.PropTypes.object + option: _react2['default'].PropTypes.object.isRequired, + style: _react2['default'].PropTypes.object, + className: _react2['default'].PropTypes.string, + theme: _react2['default'].PropTypes.string, + onChartReady: _react2['default'].PropTypes.func, + showLoading: _react2['default'].PropTypes.bool, + onEvents: _react2['default'].PropTypes.object }, // first add componentDidMount: function componentDidMount() { @@ -52,7 +52,7 @@ var ReactEcharts = _react2.default.createClass({ if (typeof this.props.onChartReady === 'function') this.props.onChartReady(echartObj); // on resize - (0, _elementResizeEvent2.default)(this.refs.echartsDom, function () { + (0, _elementResizeEvent2['default'])(this.refs.echartsDom, function () { echartObj.resize(); }); }, @@ -64,7 +64,7 @@ var ReactEcharts = _react2.default.createClass({ // remove componentWillUnmount: function componentWillUnmount() { - _echarts2.default.dispose(this.refs.chart); + _echarts2['default'].dispose(this.refs.chart); }, // render the dom @@ -81,14 +81,14 @@ var ReactEcharts = _react2.default.createClass({ }, getEchartsInstance: function getEchartsInstance() { // return the echart object - return _echarts2.default.getInstanceByDom(this.refs.echartsDom) || _echarts2.default.init(this.refs.echartsDom, this.props.theme); + return _echarts2['default'].getInstanceByDom(this.refs.echartsDom) || _echarts2['default'].init(this.refs.echartsDom, this.props.theme); }, render: function render() { var style = this.props.style || { height: '300px' }; // for render - return _react2.default.createElement('div', { ref: 'echartsDom', + return _react2['default'].createElement('div', { ref: 'echartsDom', className: this.props.className, style: style }); } }); -exports.default = ReactEcharts; \ No newline at end of file +exports['default'] = ReactEcharts; \ No newline at end of file diff --git a/package.json b/package.json index b0e8278..ace1a67 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,9 @@ "cross-env": "^1.0.8", "echarts": "^3.1.1", "element-resize-event": "^2.0.5", - "react-router": "^2.0.0" + "react-router": "^2.0.0", + "babel-plugin-transform-es3-property-literals": "*", + "babel-plugin-transform-es3-member-expression-literals": "*" }, "dependencies": { "echarts": "^3.1.1",