Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Charts - Formatting Date in Line Chart Tooltip

In Google Charts, is there a way to change the date formatting of the tooltip value, without making it an HTML tooltip. For example, by default I get this:

tooltip without formatting

But what I really want is this:

tooltip with formatting

The chart code is as following:

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',
    },
});
like image 215
Tzach Avatar asked Mar 03 '14 13:03

Tzach


People also ask

Is Google Charts deprecated?

While the dynamic and interactive Google Charts are actively maintained, we officially deprecated the static Google Image Charts way back in 2012. This gives us the right to turn it off without notice, which may happen soon.

What is tooltip in Datastudio?

Tooltips are a user interface element that pops up when you hover over a component on the screen. They display additional information for the component, and they're a great way to create meaningful yet decluttered data visualizations.


1 Answers

Found the solution, using 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
like image 94
Tzach Avatar answered Sep 23 '22 16:09

Tzach