Format a time as hours:minutes on a Google Charts y-axis

前端 未结 2 1640
借酒劲吻你
借酒劲吻你 2021-01-06 03:33

I have a Google Chart where the y-axis is measured in minutes.

How can I format the y-axis so the labels display the time in a format like 2hrs40

相关标签:
2条回答
  • 2021-01-06 04:31

    The formatting options don't allow you to do that. You can, however, use the vAxis.ticks option to manually specify the values to use for the tick marks and the strings you want to use to represent the values. The vAxis.ticks option takes an array of objects, where each object has v (value) and f (formatted value - what gets displayed on the chart) properties. Something like this should work:

    vAxis: {
        ticks: [{v: 0, f: '0:00'}, {v: 30, f: '0:30'}, {v: 60, f: '1:00'}, {v: 90, f: '1:30'}]
    }
    
    0 讨论(0)
  • 2021-01-06 04:34

    Google lets you do that....I'm doing this to show data like "5 mins". In your options do this:

                vAxis: {
                format: 'm \'mins\''
            },
    
    0 讨论(0)
提交回复
热议问题