function GetDeepChart(id, select, start, end) //获取数据
{
var wt = new Date(Date.parse(end.replace(/-/g, "/")));
var nt = new Date(Date.parse(start.replace(/-/g, "/")));
var cha = wt.getTime() - nt.getTime()
var days = Math.floor(cha / (24 * 3600 * 1000))
$.post("/HarthWork/Monitor/GetMonitorDeepList", { PointId: id, select: select, start: start, end: end }, function (data) {
if (data != null) {
var Monitortext = $("#MonitorTypeTree").tree("getSelected");
$.post("/HarthWork/Monitor/GetTypeUnit", { newId: Monitortext.id }, function (typeUnit) {
if (data != null) {
var text = Monitortext.text;
var day = 1;
var danwei = typeUnit;
var ytext = '监测单位(' + danwei + ')';
var seriesname = $("#selectId").find("option:selected").text();
var mydata = eval(data);
var series = [];
for (var i = 0; i < mydata.length; i++) {
var name = mydata[i]['name'];
var mydata1 = mydata[i]['data'];
var data1 = [];
for (var j = 0; j < mydata1.length; j++) {
var date = mydata1[j].datetime;
var obj = date.split(",");
var month = obj[1] - 1;
data1.push([Date.UTC(obj[0], month, obj[2], obj[3], obj[4], obj[5]), parseFloat(mydata1[j].datavalue)]);
}
series.push({ name: name, data: data1 });
}
getline(seriesname, cha / 20, ytext, series, danwei);
}
}, "text")
}
else {
$('#container').html("");
}
})
}
function getline(seriesname, cha, ytext, series, danwei)//生成图表
{
if (cha == 0) {cha = 3600 * 1000;
}
$(function () {
$('#container').highcharts({
global: {
useUTC: false
},
chart: {
type: 'spline'
},
title: {
text: seriesname
},
xAxis: {
type: 'datetime',
tickInterval: cha,//X轴时间间隔
tickPixelInterval: 150,
labels: {
enable: true,
rotation: 75, //旋转,效果就是影响标签的显示方向
formatter: function () {
return Highcharts.dateFormat('%Y-%m-%d %H', this.value);//转换时间格式
}
}
},
yAxis: {
title: {
text: ytext
}
},
tooltip: {
formatter: function () {
return '<b>' + this.series.name + '</b><br/>' +
Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) + '<br/> ' + (this.y).toFixed(3) + danwei;//划上点的时候显示的内容
}
},
series: series//是数据 已数组的方式传入, 一般是获取一段json数据后转换为数组
});
});
}