2018-04-17 05:41:14 +00:00
|
|
|
// 修改后
|
2016-10-21 07:54:29 +00:00
|
|
|
import echarts from './echarts.min';
|
2016-10-27 06:14:35 +00:00
|
|
|
import toString from '../../util/toString';
|
2018-04-17 05:41:14 +00:00
|
|
|
var myChart = null;
|
|
|
|
|
export default function renderChart(props,isFirst) {
|
|
|
|
|
// const height = props.height || 400;
|
2017-05-15 06:48:47 +00:00
|
|
|
const height = `${props.height || 400}px`;
|
|
|
|
|
const width = props.width ? `${props.width}px` : 'auto';
|
2018-04-17 05:41:14 +00:00
|
|
|
if (isFirst){
|
|
|
|
|
return `
|
2017-05-15 06:48:47 +00:00
|
|
|
document.getElementById('main').style.height = "${height}";
|
|
|
|
|
document.getElementById('main').style.width = "${width}";
|
2018-04-17 05:41:14 +00:00
|
|
|
myChart = echarts.init(document.getElementById('main'));
|
2016-11-01 09:31:14 +00:00
|
|
|
myChart.setOption(${toString(props.option)});
|
|
|
|
|
`
|
2018-04-17 05:41:14 +00:00
|
|
|
}else{
|
|
|
|
|
return `
|
|
|
|
|
document.getElementById('main').style.height = "${height}";
|
|
|
|
|
document.getElementById('main').style.width = "${width}";
|
2018-05-15 05:35:05 +00:00
|
|
|
myChart.clear();
|
2018-06-15 06:35:22 +00:00
|
|
|
myChart.resize({width:${width},height:${height}});
|
2018-04-17 05:41:14 +00:00
|
|
|
myChart.setOption(${toString(props.option)});
|
|
|
|
|
`
|
|
|
|
|
}
|
2016-10-21 07:54:29 +00:00
|
|
|
}
|