简体   繁体   中英

Google Line Chart Date format in tooltip

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);

在此输入图像描述

Format the data, before drawing the chart

var formatter = new google.visualization.DateFormat({pattern: 'MMM'});
formatter.format(data, 0);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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