Skip to content

Commit ea1e0d9

Browse files
committed
fix bug of 100px width * height, #149 #150
1 parent 8514679 commit ea1e0d9

File tree

5 files changed

+23
-11
lines changed

5 files changed

+23
-11
lines changed

demo/dist/bundle.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/core.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var EchartsReactCore = function (_Component) {
4242
var _this = _possibleConstructorReturn(this, (EchartsReactCore.__proto__ || Object.getPrototypeOf(EchartsReactCore)).call(this, props));
4343

4444
_this.getEchartsInstance = function () {
45-
return _this.echartsInstance.getInstanceByDom(_this.echartsElement) || _this.echartsInstance.init(_this.echartsElement, _this.props.theme, _this.props.opts);
45+
return _this.echartsLib.getInstanceByDom(_this.echartsElement) || _this.echartsLib.init(_this.echartsElement, _this.props.theme, _this.props.opts);
4646
};
4747

4848
_this.dispose = function () {
@@ -51,7 +51,7 @@ var EchartsReactCore = function (_Component) {
5151
try {
5252
_elementResizeEvent2['default'].unbind(_this.echartsElement);
5353
} catch (_) {}
54-
_this.echartsInstance.dispose(_this.echartsElement);
54+
_this.echartsLib.dispose(_this.echartsElement);
5555
}
5656
};
5757

@@ -63,6 +63,12 @@ var EchartsReactCore = function (_Component) {
6363

6464
var echartObj = _this.renderEchartDom();
6565
_this.bindEvents(echartObj, onEvents || {});
66+
67+
// fix bug of 100px width * height.
68+
try {
69+
echartObj.resize();
70+
} catch (_) {}
71+
6672
// on chart ready
6773
if (typeof onChartReady === 'function') _this.props.onChartReady(echartObj);
6874
// on resize
@@ -104,7 +110,7 @@ var EchartsReactCore = function (_Component) {
104110
return echartObj;
105111
};
106112

107-
_this.echartsInstance = _this.props.echarts; // the echarts object.
113+
_this.echartsLib = _this.props.echarts; // the echarts object.
108114
_this.echartsElement = null; // echarts div element
109115
return _this;
110116
}

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var EchartsReact = function (_EchartsReactCore) {
3030

3131
var _this = _possibleConstructorReturn(this, (EchartsReact.__proto__ || Object.getPrototypeOf(EchartsReact)).call(this, props));
3232

33-
_this.echartsInstance = _echarts2['default'];
33+
_this.echartsLib = _echarts2['default'];
3434
return _this;
3535
}
3636

src/core.jsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const isEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
77
export default class EchartsReactCore extends Component {
88
constructor(props) {
99
super(props);
10-
this.echartsInstance = this.props.echarts; // the echarts object.
10+
this.echartsLib = this.props.echarts; // the echarts object.
1111
this.echartsElement = null; // echarts div element
1212
}
1313

@@ -50,8 +50,8 @@ export default class EchartsReactCore extends Component {
5050
}
5151

5252
// return the echart object
53-
getEchartsInstance = () => this.echartsInstance.getInstanceByDom(this.echartsElement) ||
54-
this.echartsInstance.init(this.echartsElement, this.props.theme, this.props.opts);
53+
getEchartsInstance = () => this.echartsLib.getInstanceByDom(this.echartsElement) ||
54+
this.echartsLib.init(this.echartsElement, this.props.theme, this.props.opts);
5555

5656
// dispose echarts and element-resize-event
5757
dispose = () => {
@@ -60,7 +60,7 @@ export default class EchartsReactCore extends Component {
6060
try {
6161
elementResizeEvent.unbind(this.echartsElement);
6262
} catch (_) {}
63-
this.echartsInstance.dispose(this.echartsElement);
63+
this.echartsLib.dispose(this.echartsElement);
6464
}
6565
};
6666

@@ -69,6 +69,12 @@ export default class EchartsReactCore extends Component {
6969

7070
const echartObj = this.renderEchartDom();
7171
this.bindEvents(echartObj, onEvents || {});
72+
73+
// fix bug of 100px width * height.
74+
try {
75+
echartObj.resize();
76+
} catch (_) {}
77+
7278
// on chart ready
7379
if (typeof onChartReady === 'function') this.props.onChartReady(echartObj);
7480
// on resize

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ import EchartsReactCore from './core';
55
export default class EchartsReact extends EchartsReactCore {
66
constructor(props) {
77
super(props);
8-
this.echartsInstance = echarts;
8+
this.echartsLib = echarts;
99
}
1010
}

0 commit comments

Comments
 (0)