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>