How to reverse vertical axis data order

24 views
Skip to first unread message

Paul Preston

unread,
Jul 29, 2014, 3:49:22 AM7/29/14
to google-visua...@googlegroups.com
I have a chart (and code below) where the vertical axis needs to show 1 at the top and the highest number at the bottom, at the moment it is the other way around - how do I this?

Thanks in advance for your help
Paul

Code
<html>
  <head>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart"]});
      google.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = google.visualization.arrayToDataTable([
          ['Month', 'UK Rank', 'SOR 2014 Rank'],
          ['May 14',  47,      28],
          ['July 14b',  43,      6],
          ['July 14e',  40,       4],        
        ]);

        var options = {
          title: 'Rankings Tracker'
                            };

        var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
        chart.draw(data, options);getVAxisValue(0,-1)

      }
    </script>
  </head>
  <body>
    <div id="chart_div" style="width: 900px; height: 500px;"></div>

  </body>
</html>

Andrew Gallant

unread,
Jul 29, 2014, 8:45:52 AM7/29/14
to google-visua...@googlegroups.com
Set the vAxis.direction option to -1.

Paul Preston

unread,
Jul 31, 2014, 4:07:19 AM7/31/14
to google-visua...@googlegroups.com
Thanks Andrew but where in the code do I put the vAxis bit?

Paul


--
You received this message because you are subscribed to a topic in the Google Groups "Google Visualization API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-visualization-api/sWmPv4Subco/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Andrew Gallant

unread,
Jul 31, 2014, 9:04:47 AM7/31/14
to google-visua...@googlegroups.com, pa...@scwgfl.com
You add it to your chart options:

var options = {
    title: 'Rankings Tracker',
    vAxis: {
        direction: -1
    }
};
To unsubscribe from this group and all its topics, send an email to google-visualization-api+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages