简体   繁体   English

Google图表中的双Y轴,双y轴上都有“自定义”步骤

[英]Dual Y-Axis in Google Charts With Custom step on both dual y axis

I am facing problem with amcharts dual y-axis custom step on each axis so shifting to Google Charts. 我在每个轴上都具有amcharts双y轴自定义步骤的问题,因此转移到Google图表。 Does Google Charts support dual y-axis with minimum and maximum with custom step on each axis? Google图表是否支持带有最小和最大的双y轴,并且每个轴上都有自定义步长?

Image is attached for reference: 随附图片供参考:

Amcharts双Y轴图像

to set dual y-axis, change the targetAxisIndex of one of the series ... 设置双y轴,更改series之一的targetAxisIndex ...

  series: {
    1: {
      targetAxisIndex: 1
    }
  },

to set min and max, use viewWindow 设置最小和最大,使用viewWindow
and for step, must provide own ticks 对于步骤,必须提供自己的ticks
for each vAxes 对于每个vAxes

  vAxes: {
    0: {
      viewWindow: {
        min: 0,
        max: 20
      },
      ticks: [0, 5, 10, 15, 20]
    },
    1: {
      viewWindow: {
        min: 120,
        max: 240
      },
      ticks: [120, 160, 200, 240]
    }
  }

see following working snippet... 请参阅以下工作片段...

 google.charts.load('current', { callback: function () { var data = google.visualization.arrayToDataTable([ ['Label', 'Series 0', 'Series 1'], ['a', 10, 150], ['b', 12, 180], ['c', 14, 210], ['d', 16, 240] ]); var container = document.getElementById('chart_div'); var chart = new google.visualization.ColumnChart(container); chart.draw(data, { series: { 1: { targetAxisIndex: 1 } }, vAxes: { 0: { viewWindow: { min: 0, max: 20 }, ticks: [0, 5, 10, 15, 20] }, 1: { viewWindow: { min: 120, max: 240 }, ticks: [120, 160, 200, 240] } } }); }, packages: ['corechart'] }); 
 <script src="https://www.gstatic.com/charts/loader.js"></script> <div id="chart_div"></div> 

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

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