Echarts自适应浏览器大小
var myChart = echarts.init(document.getElementById('sitesChar')); var option = { title : { text: 'Nodejs站点服务器分布', subtext: '平台组', x:'center' }, tooltip : { trigger: 'item', formatter: "{a} <br/>{b} : {c} ({d}%)" }, legend: { orient : 'vertical', x : 'left', data: _ips }, toolbox: { show : true, feature : { mark : {show: false}, dataView : {show: true, readOnly: false}, magicType : { show: false, type: ['pie', 'funnel'], option: { funnel: { x: '25%', width: '50%', funnelAlign: 'left' //max: 1548 } } }, restore : {show: true}, saveAsImage : {show: true} } }, calculable : true, series : [ { name:'服务器IP:站点数', type:'pie', radius : '55%', center: ['50%', '60%'], data: _data } ] }; // 为echarts对象加载数据 myChart.setOption(option);
// 加上这一句即可 window.onresize = myChart.resize;