mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
fix: properly format x axis for durations (see #232)
This commit is contained in:
parent
f0ac0f6153
commit
11291b0d6c
@ -34,10 +34,10 @@ Chart.defaults.global.defaultFontColor = "#E2E8F0"
|
|||||||
Chart.defaults.global.defaultColor = "#E2E8F0"
|
Chart.defaults.global.defaultColor = "#E2E8F0"
|
||||||
|
|
||||||
String.prototype.toHHMMSS = function () {
|
String.prototype.toHHMMSS = function () {
|
||||||
var sec_num = parseInt(this, 10)
|
const sec_num = parseInt(this, 10)
|
||||||
var hours = Math.floor(sec_num / 3600)
|
let hours = Math.floor(sec_num / 3600)
|
||||||
var minutes = Math.floor((sec_num - (hours * 3600)) / 60)
|
let minutes = Math.floor((sec_num - (hours * 3600)) / 60)
|
||||||
var seconds = sec_num - (hours * 3600) - (minutes * 60)
|
let seconds = sec_num - (hours * 3600) - (minutes * 60)
|
||||||
|
|
||||||
if (hours < 10) {
|
if (hours < 10) {
|
||||||
hours = '0' + hours
|
hours = '0' + hours
|
||||||
@ -48,14 +48,14 @@ String.prototype.toHHMMSS = function () {
|
|||||||
if (seconds < 10) {
|
if (seconds < 10) {
|
||||||
seconds = '0' + seconds
|
seconds = '0' + seconds
|
||||||
}
|
}
|
||||||
return hours + ':' + minutes + ':' + seconds
|
return `${hours}:${minutes}:${seconds}`
|
||||||
}
|
}
|
||||||
|
|
||||||
String.prototype.toHHMM = function () {
|
String.prototype.toHHMM = function () {
|
||||||
const sec_num = parseInt(this, 10)
|
const sec_num = parseInt(this, 10)
|
||||||
const hours = Math.floor(sec_num / 3600)
|
const hours = Math.floor(sec_num / 3600)
|
||||||
const minutes = Math.floor((sec_num - (hours * 3600)) / 60)
|
const minutes = Math.floor((sec_num - (hours * 3600)) / 60)
|
||||||
return hours + ':' + minutes
|
return `${hours}:${minutes}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw(subselection) {
|
function draw(subselection) {
|
||||||
@ -114,7 +114,10 @@ function draw(subselection) {
|
|||||||
xAxes: [{
|
xAxes: [{
|
||||||
scaleLabel: {
|
scaleLabel: {
|
||||||
display: true,
|
display: true,
|
||||||
labelString: 'Seconds'
|
labelString: 'Duration (hh:mm:ss)'
|
||||||
|
},
|
||||||
|
ticks: {
|
||||||
|
callback: (label) => label.toString().toHHMMSS()
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user