Plotting seconds, minutes and hours on the yAxis with Highcharts

前端 未结 1 380
[愿得一人]
[愿得一人] 2021-01-12 15:21

I have some data that looks like this:

min=\"00:09\" med=\"03:11\" mean=\"23:39\" max=\"12:40:26\"

I\'d like to be able to be ab

相关标签:
1条回答
  • 2021-01-12 15:57

    If the times that you have are static strings, you can convert them into a datetime object...

    //convert 'string' times into a timestamp (milliseconds)
    //so long as your string times are consistently formatted
    //e.g. "0:03:00" not "3:00"
    var t = Date.parse("1-1-1 " + yourTime)
    

    ...But if you can turn them into a millisecond value at all, you should be fine.

    Then use normal time format for the y-axis, and format it as you like using the date label format...

    var chart = new HighChart({
        //...
        yAxis: {
            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'
            }
        }
    });
    
    0 讨论(0)
提交回复
热议问题