Merge pull request #44 from superandrew213/add-width-to-echart-container

Add width
This commit is contained in:
Arron Zhu 2017-10-26 04:38:47 -05:00 committed by GitHub
commit c9efc0634f
1 changed files with 4 additions and 2 deletions

View File

@ -2,9 +2,11 @@ import echarts from './echarts.min';
import toString from '../../util/toString'; import toString from '../../util/toString';
export default function renderChart(props) { export default function renderChart(props) {
const height = props.height || 400; const height = `${props.height || 400}px`;
const width = props.width ? `${props.width}px` : 'auto';
return ` return `
document.getElementById('main').style.height = "${height}px"; document.getElementById('main').style.height = "${height}";
document.getElementById('main').style.width = "${width}";
var myChart = echarts.init(document.getElementById('main')); var myChart = echarts.init(document.getElementById('main'));
myChart.setOption(${toString(props.option)}); myChart.setOption(${toString(props.option)});
` `