<div class="layui-card-body ">
<!-- 为 ECharts 准备一个具备大小(宽高)的 DOM -->
<div id="total" style="width: 100%;height:300px;"></div>
</div>
通过ajax获取后台数据xaxisdata,totalyaxisdata.
初始化echarts实例:
var totalChart = echarts.init(document.getElementById('total'));
设置显示个数:
var exStart = 101-Math.floor((15/xaxisdata.length)*100);
具体配置:
var totaloption = {
color: ['#18629E','#18629E', '#3E88C5'],
title:{text:'总数'},
tooltip:{
trigger:'axis',
axisPointer:{
type:'line'
}
},
grid:{
top:80,
bottom:30
},
xAxis:{
data: xaxisdata,
splitNumber:20,
lineHeight:30
},
yAxis:{},
series:[
{
name:'人数',
type:'bar',
label:{
normal:{
show:true,
position:'top'
}
},
data:totalyaxisdata,
barWidth:20
}
],
dataZoom:[
{
type:'slider',
start:exStart,
end:100,
show:true,
handleSize:5
}
]
};
totalChart.setOption(totalOption);