How to 'reverse' Google Charts chart?

2

I have the following graph that I generate using Google charts:

google.charts.load('current', {packages: ['corechart', 'bar']});
google.charts.setOnLoadCallback(drawStacked);
function drawStacked() {
var data = google.visualization.arrayToDataTable([
['Ativo', 'Qtd. de erros'],
<?php
   $b = 0;
   while($b < 5){
   echo "['".$tabela['Papel'][$b].", ".$tabela['usuario'][$b]."',".$tabela['Tot_papel'][$b]."],";
   $b++;
   }
   ?>
]);
var options = {
title: 'Ranking qtd. de erros por ativos',
isStacked: true,
hAxis: {
title: 'Qtd de erros',
minValue: 0,
},
vAxis: {
title: 'Ativos'
}
};
var chart = new google.visualization.BarChart(document.getElementById('chart_div'));
chart.draw(data, options);
}

The% wired call:

<div id="chart_div" class="gogl" style="width: 600px; height: 300px"></div>

All this generates the following chart:

The bars go from left to right, I wanted the chart to be the mirror of what it is now, from right to left.

    
asked by anonymous 20.04.2018 / 21:48

1 answer

2

Simply assign% w / o% to the direction of the axis you want to invert:

  

vAxis.direction or hAxis.direction

     

Indicates the direction in which the values along the axis grow.

     

Specify -1 to reverse the order of values.

     

Values accepted: 1 or -1

     

Default value: 1

     

Google charts

To invert vertically:

vAxis.direction: '-1'

To flip horizontally:

hAxis.direction: '-1'
    
23.04.2018 / 16:30