diff --git a/src/components/Echarts/renderChart.js b/src/components/Echarts/renderChart.js index 7a595f0..a76bc85 100644 --- a/src/components/Echarts/renderChart.js +++ b/src/components/Echarts/renderChart.js @@ -2,9 +2,11 @@ import echarts from './echarts.min'; import toString from '../../util/toString'; 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 ` - 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')); myChart.setOption(${toString(props.option)}); `