저는 stackoverflow, django 및 highcharts를 처음 사용하므로 불편을 끼쳐 드려 죄송합니다.
그래서 저는 현재 작은 문제를 발견했을 때 하이 차트에 시간과 날짜를 표시하는 작업을하고 있습니다. 차트를 보면 모든 것이 다음과 같이 잘 보입니다.
그러나 차트의 한 지점에 마우스를 가져 가면 다른 값이 표시됩니다. 이렇게 생겼어요
한 지점에 초점을 맞출 때 총 마이크로 초가 아니라 측면 에서처럼 HH : MM : SS로 표시되도록하고 싶습니다. 그렇게하려면 무엇을 변경해야합니까?
다음은 차트의 코드입니다.
<script>
$(function () {
$('#container').highcharts({
chart:
{
type: 'line'
},
title:
{
text: 'Time worked by {{user_to_show}}'
},
xAxis:
{
categories: {{dates|safe}}
},
yAxis:
[{
title:
{
text: ''
},
gridLineWidth: 1,
type: 'datetime', //y-axis will be in milliseconds
dateTimeLabelFormats:
{ //force all formats to be hour:minute:second
second: '%H:%M:%S',
minute: '%H:%M:%S',
hour: '%H:%M:%S',
day: '%H:%M:%S',
week: '%H:%M:%S',
month: '%H:%M:%S',
year: '%H:%M:%S'
},
opposite: true
}],
plotOptions:
{
series:
{
dataLabels:
{
enabled: true,
formatter: function()
{
if( this.series.index == 0 )
{
return secondsTimeSpanToHMS(this.y/1000) ;
}
else
{
return this.y;
}
}
}
}
},
series:
[{
name: 'Time',
yAxis: 0,
data: {{time|safe}}
}]
});
});
function secondsTimeSpanToHMS(s) {
var h = Math.floor(s / 3600); //Get whole hours
s -= h * 3600;
var m = Math.floor(s / 60); //Get remaining minutes
s -= m * 60;
return h + ":" + (m < 10 ? '0' + m : m) + ":" + (s < 10 ? '0' + s : s); //zero padding on minutes and seconds
}
</script>
더 많은 코드, 데이터 또는 정보를 원하시면 저에게 알려주십시오. 답장을 보내 주신 분들께 미리 감사드립니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다