我需要Google Charts的单列柱形图

时间:2016-02-14 18:33:37

标签: charts google-visualization

我需要一个单列柱形图,其垂直轴从0到150000,并且需要一个填充它的条形图(它们完全符合它们的免赔额)。我以为我读到的东西如下所示,但这给了我一个0到400,000的垂直轴和一个高达150,000的条。

或者,我可以使用有关如何显示单个字段的建议,而可以支付全额或4次付款以满足该免赔额。

请帮忙!

<script type="text/javascript">
    google.charts.load('current', {'packages':['corechart']});

    google.charts.setOnLoadCallback(barDisassembly);

    function barDisassembly() {
        var data = google.visualization.arrayToDataTable([
            ['Categories', 'Disassembly Fee'],
            ['N-1701', 150000]
        ]);

        var options = {
            chart: {
                width: 200,
                height: 400,
                legend: { position: 'top', maxLines: 3 },
                vAxis: {
                    viewWindowMode:'explicit',
                    viewWindow:{
                        max:150000,
                        min:0
                    }
                }
            }
        };

        var bar = new google.visualization.ColumnChart(document.getElementById('bar_disassembly'));

        bar.draw(data, options);
    }
</script>

1 个答案:

答案 0 :(得分:0)

从选项中删除chartchart相关联的唯一configuration optionssubtitletitle ...

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

google.charts.setOnLoadCallback(barDisassembly);

function barDisassembly() {
  var data = google.visualization.arrayToDataTable([
    ['Categories', 'Disassembly Fee'],
    ['N-1701', 150000]
  ]);

  var options = {
    width: 400,
    height: 400,
    legend: {
      position: 'top',
      maxLines: 3
    },
    vAxis: {
      viewWindow: {
        max: 150000,
        min: 0
      }
    }
  };

  var bar = new google.visualization.ColumnChart(document.getElementById('bar_disassembly'));

  bar.draw(data, options);
}
&#13;
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="bar_disassembly"></div>
&#13;
&#13;
&#13;