我有一个列,该列是我要在Google图表图表中用来表示持续时间的毫秒数。如何将该数字转换为时间跨度?

最佳答案

为了扩展肯尼的答案,如果您输入数据以毫秒为单位,则可以使用DataView将其转换为timeofday数据类型:

var timeFormatter = new google.visualization.DateFormat('HH:mm:ss.SSS'); // set this pattern however you need to format your time display
var view = new google.visualization.DataView(data);
view.setColumns([/* columns before timeofday */, {
    type: 'timeofday',
    label: 'Time of Day',
    calc: function (dt, row) {
        var timeOfDay = toTimeSpan(data.getValue(row, /* time column index */);
        var formattedTime = timeFormatter.formatValue(timeOfDay);
        return {v: timeOfDay, f: formattedTime};
    }
}, /* columns after timeofday */]);

10-06 00:41