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

本文介绍了一个使用jQuery和HighCharts库实现的应用程序接口(API),该接口用于获取指定应用ID的平均加载时间趋势,并将其可视化展示为图表。具体包括设置HTTP请求参数、处理返回的数据并绘制曲线图的过程。
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");
}
});


}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值