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;