Google Chart中的Trippe Y轴可视化问题

问题描述 投票:1回答:1

我在第三个变量上的Y轴范围遇到问题,我尝试添加最小值,最大值,视图范围,但是因为它是一个百分比,并且根据体积/价格的大小而变得越来越不可见。任何想法或帮助都将大大鼓励。这是以下设置的图形:

enter image description here

<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart"></div>
<script>

google.charts.load('current', {
                   callback: function () {
                   var data = new google.visualization.DataTable({
                                                                 cols: [
                                                                 {label: 'Time', type: 'string', format: 'decimal'},
                                                                 {label: 'Volume', type: 'number'},
                                                                 {label: '฿', type: 'number'},
                                                                 {label: 'Buy %', type: 'number'},
                                                                 ],
                                                                 rows: [
                                                                 <?php
                                                                 while($row = mysqli_fetch_assoc($result)) {
                                                                 echo "{c:[{v: '" . $row["Timestamp"] . "'}, {v:" . $row["Volume"] . "}, {v:" . $row["LastPrice"] . "}, {v:" . $row["buyers"]*100 . "}]},";
                                                                 }
                                                                 ?>
                                                                 ]
                                                                 });

                   var container = document.getElementById('chart');
                   var formatter = new google.visualization.NumberFormat({
                                                                         fractionDigits: 8
                                                                         });
                   formatter.format(data, 2);
                   var chart = new google.visualization.LineChart(container);
                   chart.draw(data, {
                              height: 525,
                              crosshair: { trigger: 'both' },
                              series: {
                              1: {
                              targetAxisIndex: 1,
                              }
                              },
                              theme: 'material',

                              vAxes: {
                              0: {
                              title: '',
                              },
                              1: {
                              title: '',
                              },
                              2: {
                              title: '',
                              minValue: 0,
                              maxValue: 100,
                              format: '#\'%\'',
                              }
                              },

                              });

                   },
                   packages: ['corechart']
                   });

</script>
javascript charts google-visualization
1个回答
1
投票

尝试将每个系列分配到自己的轴......

series: {
  1: {
    targetAxisIndex: 1
  },
  2: {
    targetAxisIndex: 2
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.