//折线图
$(function() {
tiwen();//体温
functiontiwen() {//基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('tiwen'));
option={
title:{//text:'EChars入门'
},
grid:{
x:35,
y:35,
x2:25,
y2:40,
},
tooltip: {
trigger:'axis'},
xAxis: {
type:'category',
data: [],
axisLabel: {
margin:10,
color:'#777',
},
axisLine: {
lineStyle: {
color:'rgba(107,107,107,1)',
}
},
},
yAxis: {
type:'value',
splitNumber:2,
scale:true,//minInterval: 1,
maxInterval: 3600 * 24 * 1000,
axisLabel: {
color:'#555',
margin:6},
axisLine: {
lineStyle: {
color:'rgba(107,107,107,0.2)',
}
},
splitLine: {
lineStyle: {
type:'dashed',
color:'rgba(131,101,101,0.3)'}
},
},
series: [{
name:'体温',
data: [],
type:'line',
lineStyle: {
normal: {
width:2,
color: {
type:'linear',
colorStops: [{
offset:0,
color:'#48D8BF' //0% 处的颜色
}, {
offset:1,
color:'#48D8BF' //100% 处的颜色
}],
globalCoord:false //缺省为 false
}
}
},
itemStyle: {
normal: {
color:'#48D8BF',
borderColor:"#5b92c9"}
},
smooth:true}]
};//使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
window.addEventListener("resize",function(){
myChart.resize();
});//异步加载数据
$.get("getTiwen.html?cardid="+cardid+"").done(function(data) {if (data.code == 200) {//后台传过来的数据
var createdate =data.data.createdatevar tiwen =data.data.tiwen
}else{//默认值
var createdate = ['03/01','03/02','03/03','03/04','03/05','03/06','03/07']var tiwen = [62,64,62,63,63,64,63]
}//填入数据
myChart.setOption({
xAxis: {
data: createdate
},
series: [{
data: tiwen
}]
});
});
}
})