这里我有一系列数据,而有些系列的持续时间为00:12:00
,其他系列的值为int
,
这是我的Javascript代码(您也可以在JSFiddle上查看):
$(function () {
$('#container').highcharts({
chart: {
type: 'line',
inverted: false
},
title: {
text: 'Duration Data'
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
yAxis: {
min: 0,
type: "datetime",
title: {
text: 'Time Duration'
},
lineWidth: 2,
labels: {
formatter: function () {
var ts = this.value,
hs = ts / (3600 * 1000),
ms = new Date(ts).getUTCMinutes();
sc = new Date(ts).getUTCSeconds();
sc = sc < 10 ? '0' + sc : sc;
ms = ms < 10 ? '0' + ms : ms;
hs = hs < 10 ? '0' + hs : hs;
if(hs > 1)
return hs + ":" + ms +":" + sc;
else
return ms +":" + sc;
}
}
},
tooltip:{
formatter:function() {
return Highcharts.dateFormat('%H:%M:%S',this.y);
}
},
legend: {
enabled: false
},
plotOptions: {
spline: {
marker: {
enable: false
}
}
},
series: [{
name: 'Time',
data: [600000, 2520000,75610000]
},
{
name: 'Price',
data: [12,778,123]
}]
});
});
这是我的HTML代码:
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div>
如何区分High Chart中的多个系列数据?
答案 0 :(得分:1)
试试这个:
tooltip:{
formatter:function() {
var a = Highcharts.dateFormat('%H:%M:%S',this.y);
if(a === "00:00:00"){
return this.y;
}else{
return a;
}
}
}