3

Here's some example data:

Best running time on 1000 ft depending on age:

               | 7 yrs | 8 yrs | 9 yrs | ...
--------------------------------------------
time, seconds  |  100  |  80   |  70   |

I want time (on Y axis) to displayed as a formatted value, not just plain number. This could be anything readable like 01:23. Failed to find any working example

WhiteHat
  • 59,912
  • 7
  • 51
  • 133
Dan
  • 55,715
  • 40
  • 116
  • 154

1 Answers1

2

Use 'timeofday' column type for y-axis

From the docs --> Working with Timeofday

See following working snippet...

google.charts.load('current', {
  callback: drawChart,
  packages:['corechart']
});

function drawChart() {
  var data = google.visualization.arrayToDataTable([
    ['', ''],
    [7, [0, 1, 40]],
    [8, [0, 1, 20]],
    [9, [0, 1, 10]],
    [10, [0, 0, 59]]
  ]);

  var container = document.getElementById('chart_div');
  var chart = new google.visualization.ScatterChart(container);
  chart.draw(data);
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>
Dan
  • 55,715
  • 40
  • 116
  • 154
WhiteHat
  • 59,912
  • 7
  • 51
  • 133
  • although not `'timeofday'` -- see [this answer](http://stackoverflow.com/a/39862037/5090771) for adding custom axis labels using `ticks` – WhiteHat Oct 18 '16 at 17:45
  • I've updated your code snippet, because it was not really working... or I did not explain the question well – Dan Oct 18 '16 at 19:52
  • Oh! Now I get it. Google Charts API automatically detects the column type and treats the inner array as time – Dan Oct 18 '16 at 19:55