繁体   English   中英

Google图表 - 在折线图工具提示中格式化日期

[英]Google Charts - Formatting Date in Line Chart Tooltip

在Google Charts中,有没有办法更改工具提示值的日期格式,而不是将其作为HTML工具提示。 例如,默认情况下我得到这个:

没有格式化的工具提示

但我真正想要的是:

带格式的工具提示

图表代码如下:

data_table = google.visualization.arrayToDataTable(graph_data_raw);
chart = new google.visualization.LineChart(document.getElementById('DivGraph'));
chart.draw(data_table, {
    hAxis: {
        ticks: x_ticks,
        format: 'MMM d, y',
    },
});

使用DateFormat找到解决方案:

var date_formatter = new google.visualization.DateFormat({ 
    pattern: "MMM dd, yyyy"
}); 
date_formatter.format(data_table, 0);  // Where 0 is the index of the column

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM