Re: [visualization-api] stacked chart vertical vs horizontal

15 views
Skip to first unread message

Daniel LaLiberte

unread,
Jul 13, 2016, 8:11:24 PM7/13/16
to Google Visualization API
Use ColumnChart instead of BarChart, or just add the orientation: 'horizontal' option.

On Tue, Jul 5, 2016 at 2:07 PM, Michael X <ma8...@gmail.com> wrote:
hi 

how can i switch the axis in stacked chart  , for example :

need to draw   population on Y axis instead of X.


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

google.charts.setOnLoadCallback(drawStacked);


function drawStacked() {

      var data = google.visualization.arrayToDataTable([

        ['City', '2010 Population', '2000 Population'],

        ['New York City, NY', 8175000, 8008000],

        ['Los Angeles, CA', 3792000, 3694000],

        ['Chicago, IL', 2695000, 2896000],

        ['Houston, TX', 2099000, 1953000],

        ['Philadelphia, PA', 1526000, 1517000]

      ]);


      var options = {

        title: 'Population of Largest U.S. Cities',

        chartArea: {width: '50%'},

        isStacked: true,

        hAxis: {

          title: 'Total Population',

          minValue: 0,

        },

        vAxis: {

          title: 'City'

        }

      };

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

      chart.draw(data, options);

    }



thanks
Michael

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/1b32882b-2670-407f-a091-eba912c74282%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages