有没有办法更改 Google Chart 中工具提示的日期格式?我不想把它变成 HTML,因为它完全适合我的需要。我只想有其他日期格式。如您所见,我更改了 hAxis 的格式,并且我想对工具提示执行相同的操作。
var data = google.visualization.arrayToDataTable([[{"label":"Month","type":"date"},"Customers"],[new Date('2017-01-01'),30],[new Date('2017-02-01'),45],[new Date('2017-03-01'),55],[new Date('2017-04-01'),40],[new Date('2017-05-01'),20],[new Date('2017-06-01'),17],[new Date('2017-07-01'),15],[new Date('2017-08-01'),18],[new Date('2017-09-01'),0],[new Date('2017-10-01'),0],[new Date('2017-11-01'),0],[new Date('2017-12-01'),0]]);
var options = {"legend":{"position":"bottom"},"pointSize":5,"hAxis":{"format":"MMM","ticks":[new Date('2017-01-01'),new Date('2017-02-01'),new Date('2017-03-01'),new Date('2017-04-01'),new Date('2017-05-01'),new Date('2017-06-01'),new Date('2017-07-01'),new Date('2017-08-01'),new Date('2017-09-01'),new Date('2017-10-01'),new Date('2017-11-01'),new Date('2017-12-01')]},"height":300};
var c = new google.visualization.LineChart(document.getElementById("div-chartw0"));
c.draw(data, options);
最佳答案
在绘制图表之前格式化数据
var formatter = new google.visualization.DateFormat({pattern: 'MMM'});
formatter.format(data, 0);
关于javascript - 工具提示中的 Google 折线图日期格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42626859/