0
votes

I have a Google Annotation chart showing values between 0 and 1 as seen here: jsfiddle

  google.setOnLoadCallback(drawChart);
  function drawChart() {
    var data = new google.visualization.DataTable();
    data.addColumn('date', 'Date');
    data.addColumn('number', 'Kepler-22b mission');
    data.addColumn('string', 'Kepler title');
    data.addColumn('string', 'Kepler text');
    data.addColumn('number', 'Gliese 163 mission');
    data.addColumn('string', 'Gliese title');
    data.addColumn('string', 'Gliese text');
    data.addRows([
      [new Date(2314, 2, 15), 0.12400, undefined, undefined,
                              0.10645, undefined, undefined],
      [new Date(2314, 2, 16), 0.24045, 'Lalibertines', 'First encounter',
                              0.12374, undefined, undefined],
      [new Date(2314, 2, 17), 0.35022, 'Lalibertines', 'They are very tall',
                              0.15766, 'Gallantors', 'First Encounter'],
      [new Date(2314, 2, 18), 0.12284, 'Lalibertines', 'Attack on our crew!',
                              0.34334, 'Gallantors', 'Statement of shared principles'],
      [new Date(2314, 2, 19), 0.8476, 'Lalibertines', 'Heavy casualties',
                              0.66467, 'Gallantors', 'Mysteries revealed'],
      [new Date(2314, 2, 20), 0, 'Lalibertines', 'All crew lost',
                              0.79463, 'Gallantors', 'Omniscience achieved']
    ]);

    var chart = new google.visualization.AnnotationChart(document.getElementById('chart_div'));

    var options = {
      displayAnnotations: true,
      scaleFormat: '#'
    };

    chart.draw(data, options);
  }

By default, the vertical axis is formatted as integer, which is not ideal for reading the chart. The documentation has a scaleFormat option (default '#' for integer) but does not give any alternatives. I cannot get any other number format options in the documentation to work.

How can I format the Y Axis ticks as numbers with 1 decimal?

1

1 Answers

1
votes

# is just an example, you can format that any way you want. For number with 1 decimal, you need to do:

scaleFormat: '#.#'