简体   繁体   English

Google Charts Material Bar沿水平方向四舍五入

[英]Google Charts Material Bar rounds on horizontal orientation

how to fix the rounding in Googles Chart Material Bar if the bar is horizontal. 如果水平线是水平的,如何在Google图表材料栏中修复舍入。

It shows the right numbers as decimal on vertical, but not on horizontal orientation. 它将正确的数字显示为垂直的十进制,但不显示水平的方向。

http://jsfiddle.net/8zbcv9c2/1/ 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. options因为您希望格式在水平轴而不是垂直轴上为十进制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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