ECharts折线图渲染json格式数据(json格式,为数组)
需要对数组进行循环取值,将取到的值分别赋值给x轴和y轴
json格式,data为数组
{
"msg": "查询成功",
"code": 1,
"data": [{
"statTime": "2021-03",
"noPatrolNum": 21
}, {
"statTime": "2021-04",
"noPatrolNum": 15
}]
}
demo
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/echarts/4.2.1-rc1/echarts.min.js" type="text/javascript"></script>
</head>
<body>
<!-- 为ECharts准备一个具备大小(宽高)的Dom -->
<div id="main" class="col-md-12 col-sm-12 col-xs-12" style="height: 400px;"></div>