18
votes

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',
    },
});
1

1 Answers

34
votes

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