$.ajax({
type: "Get",
url: "/xx/xxx",
data: { year: $("#year").val() },
dataType: "json",
success: function (result) {
if (echarts_model2 == null) echarts_model2 = echarts.init($("#chart_div2")[0]);
var option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
}
},
legend: {
data: ['年度计划', '执行情况']
},
grid: {
left: '10%',
bottom: '42%'
},
xAxis: {
type: 'category',
data: result.Name,
axisLabel: {
interval: 0,
rotate: 30
}
},
yAxis: {
type: 'value',
name: '单位:个',
minInterval: 1
},
series: [
{
name: '执行情况',
color: ['#08ACD6'],
type: 'line',
data: result.Fact_Data
}, {
name: '年度计划',
color: ['#f09e3d'],
type: 'line',
data: result.Plan_Data
},
]
};
echarts_model2.setOption(option, true);
},
error: function (str) {
alert("服务器连接失败!");
}
});
如图: