Reputation: 131
Is there a way to change format of date of the tooltip in Google Chart? I don't want make it an HTML because it's fully suits my need. I just want to have other date format. As you can see I changed format of hAxis and I want to do the same for tooltip.
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);
Upvotes: 3
Views: 4168
Reputation: 61222
Format the data, before drawing the chart
var formatter = new google.visualization.DateFormat({pattern: 'MMM'});
formatter.format(data, 0);
Upvotes: 15