19

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 Answer 1

36

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
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.