作者:狠毒的水瓶_617_223_489_321 | 来源:互联网 | 2023-02-09 19:24
有没有办法在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);
1> WhiteHat..:
在绘制图表之前格式化数据
var formatter = new google.visualization.DateFormat({pattern: 'MMM'});
formatter.format(data, 0);