Echarts插件,求簡答獲得不了option.legend.data屬性
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="../Common/Common/taglibs.jsp"%>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>ECharts-基本線性圖及其配置要求</title>
<script src="Static/js/MyChart/esl.js" type="text/javascript"></script>
</head>
<body>
${subSystemCodeList }
<div id="main" style="height: 400px; width:800px; border: 1px solid #ccc; padding: 10px;">
</div>
<script type="text/javascript" language="javascript">
// 按需加載
// Step:3 conifg ECharts's path, link to echarts.js from current page.
// Step:3 為模塊加載器配置echarts的路徑,從當前頁面鏈接到echarts.js,定義所需圖表路徑
require.config({
paths: {
echarts: './Static/js/MyChart/echarts' //echarts.js的路徑
}
});
// 使用
require(
[
'echarts',
'echarts/chart/pie' // 使用柱狀圖就加載bar模塊,按需加載
], DrawEChart //異步加載的回調函數繪制圖表
);
function DrawEChart(ec) {
// 基于準備好的dom,初始化echarts圖表
var myChart = ec.init(document.getElementById('main'));
var option = {
title : {
text: '系統接口統計',
subtext: '真實有效',
x:'center'
},
tooltip : {
trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
legend: {
orient : 'vertical',
x : 'left',
data:[]
},
toolbox: {
show : true,
feature : {
mark : {show: true},
dataView : {show: true, readOnly: false},
magicType : {
show: true,
type: ['pie', 'funnel'],
option: {
funnel: {
x: '25%',
width: '50%',
funnelAlign: 'left',
max: 1548
}
}
},
restore : {show: true},
saveAsImage : {show: true}
}
},
calculable : true,
series : [
{
name:'數據統計',
type:'pie',
radius : '55%',
center: ['50%', '60%'],
data:[]
}
]
};
$.ajax({
type : "post",
async : false, //同步執行
url : "${pageContext.request.contextPath}/sysinter/getSysInter",
data : {},
dataType : "json", //返回數據形式為json
success : function(result) {
if (result) {
alert(JSON.stringify(result));
option.legend.data = result.interfaceUDID;
alert(option.legend);
option.series.data = result.cs;
myChart.hideLoading();
myChart.setOption(option);
}
},
error : function(errorMsg) {
alert("不好意思,大爺,圖表請求數據失敗啦!");
myChart.hideLoading();
}
});
}
</script>
</body>
</html>