87,910
社区成员
发帖
与我相关
我的任务
分享
var chart = new Highcharts.Chart({
chart: {
height: 130,
renderTo: "container",
type: 'spline',
marginRight: 10,
events: {
load: function () {
// 每秒更新一次数据
var series = this.series[0];
setInterval(function () {
$.post("DataManager.ashx", { type: "getspots", name: name }, function (data) {
for (var x = 0; x < data.length; x++) {//筛选所需数据
if (data[x].value != "") {
if (data[x].name == name) {
realvalue = data[x].value;
}
}
}
}, 'json')
if (realvalue == undefined) {//排除异常数据
realvalue = 0;
}
else {
if (realvalue == "运行") {//特殊值
realvalue = 1;
}
realvalue = parseInt(realvalue);//转类型
}
var x = (new Date()).getTime() + 8 * 60 * 60 * 1000, // current time
y = realvalue;
series.addPoint([x, y], true, true);
}, 1000);
}
}
},
title: {
text: null
},
xAxis: {//X轴设置
type: 'datetime',
tickPixelInterval: 150
},
yAxis: {//Y轴设置
title: {
text: null
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {//提示窗显示信息
formatter: function () {
return '<b>' + this.series.name + '</b><br/>' +
Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) + '<br/>' +
Highcharts.numberFormat(this.y, 2);
}
},
legend: {
enabled: false
},
credits: {
enabled: false
},
exporting: {
enabled: false
},
plotOptions:{//
area: {
point: {
events: {
update: function () {
alert("asa")
//alert("change");
return false;
}
}
}
}
},
series: [{//数据集
name: name,
data: (function () {
var data = [],
time = (new Date()).getTime(),
i;
for (i = -180; i <= 0; i++) {
data.push({
x: time + i * 1000 + 8 * 60 * 60 * 1000,//这里取到的是格林志时间, 大约差8个小时
y: function () {
return 0;
}
});
}
return data;
})()
}]
});
spline: {
lineWidth: 1.5,// 线条粗线
fillOpacity: 0.1, //
marker: {
enabled: false, //不显示点
states: {
hover: {
enabled: true, //mouseover 时显示点
radius: 5 // mouseover 时 点的大小
}
}
},
shadow: false
}