简体   繁体   中英

Google Charts Material Bar rounds on horizontal orientation

how to fix the rounding in Googles Chart Material Bar if the bar is horizontal.

It shows the right numbers as decimal on vertical, but not on horizontal orientation.

http://jsfiddle.net/8zbcv9c2/1/

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

google.charts.setOnLoadCallback(drawChart);

function drawChart() {
  var data = google.visualization.arrayToDataTable([
    ['Artikel', 'Preis']
            ,['Felgen1',199.67] //200 im Tooltip
      ,['Felgen2',194.41] //194 im Tooltip
            ,['Reifen1',162.82] //163 im Tooltip
            ,['Reifen2',183.78] //184 im Tooltip
      ]);

  var options = {
    title: 'Ø Preis Horizontal',
      bar: { orientation: 'horizontal' },
    vAxis: {
        format: 'decimal'
    }
  };
  var chart = new google.charts.Bar(document.getElementById('barchart_material'));

  chart.draw(data, google.charts.Bar.convertOptions(options));
}

It should be:

hAxis: {
    format: 'decimal'
}

instead of

vAxis: {
    format: 'decimal'
}

in options as you want the format to be decimal in the horizontal axis and not the vertical axis.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM