Highcharts 曲线图 控制y轴动态显示 时分秒的格式数据

function load_app_id_avgTime(url,app_id,trendtype,datetype){

var datas="";
var date = [];
var count = [];
var count_type ="";
$("#trends_time_load").removeClass("hidden");//显示等待加载数据的图标
$.ajax({
url: url,
//请求数据
type: "POST",
async: true,
data: {
"app_id":app_id,
"trendtype":trendtype,//
"datetype":datetype
},
dataType: "json",
success: function(datas) {

count_type=datas.name;
for (j in datas.data) {
date.push(j);
count.push(datas.data[j]);
}
$("#trends_time_load").addClass("hidden");//隐藏加载的图标
datas = "[{name: '" + count_type + "',data:[" + count + "]}]"; //组装数据图
$('#trends_chartcontainer').highcharts({
chart: {
type: 'spline'
},
title: {
text: ''
},
subtitle: {
text: ''
},
xAxis: {
categories:eval(date),
labels:{
step:7,
rotation: 1,
align:'right'
}
},
yAxis: {
title: {
text: ''
},
min:0,
labels: {
formatter: function() {
var hh = Math.floor(this.value / 3600);
var mm = Math.floor(this.value % 3600 / 60);
var ss = Math.floor(this.value % 60);
if (hh != 0) {
return hh + '时' +mm + '分'+ ss + '秒';
}else{
return mm + '分'+ ss + '秒';
}
}
}
},
tooltip: {
enabled: true,
formatter: function() {
var hh = Math.floor(this.y / 3600);
var mm = Math.floor(this.y % 3600 / 60);
var ss = Math.floor(this.y % 60);
if (hh == 0) {
return this.x + ' ' + this.series.name + ' : ' + mm +'分' + ss +'秒';
} else {
return this.x + ' ' + this.series.name + ' : ' + hh + '时' + mm +'分' + ss + '秒';
}
}
},
plotOptions: {
spline: {//控制曲线的粗细
lineWidth: 2,
states: {
hover: {
lineWidth: 2
}
},
marker: {
enabled: false
}

},
line: {
dataLabels: {
enabled: true
},
enableMouseTracking: false
}
},
series: eval(datas)
});

},
error: function(data) {
alert("load data error");
}
});


}

你可能感兴趣的:(Highcharts)