使用echarts 实例:
<script type="text/javascript">
var date = "<?= $date?>";
var new_students = "<?= $new_students?>";
var total_students = "<?= $total_students?>";
date = date.split(",");
new_students = new_students.split(",");
total_students = total_students.split(",");
console.log(total_students[1]);
var myChart = echarts.init(document.getElementById('main'));
// 指定图表的配置项和数据
var option = {
title: {
text: ''
},
tooltip: {
trigger: 'axis'
},
legend: {
data:['新增医生','医生总人数']
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
toolbox: {
feature: {
saveAsImage: {}
}
},
xAxis: {
type: 'category',
boundaryGap: false,
data: [date[0],date[1],date[2],date[3],date[4],date[5],date[6],]
},
yAxis: {
type: 'value'
},
series: [
{
name:'新增医生',
type:'line',
// stack: '总量',
data:[new_students[0],new_students[1],new_students[2],new_students[3],new_students[4],new_students[5],new_students[6]]
},
{
name:'医生总人数',
type:'line',
// stack: '总量', 如果不删除 则计算的是累计
data:[total_students[0],total_students[1],total_students[2],total_students[3],total_students[4],total_students[5],total_students[6]]
}
]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
</script
stack 如果使用则是累计统计数,根据情况设置 ,如不需要则不添加