简体   繁体   English

如何使用Google Chart Tools为Y轴创建一个具有两个不同比例的(条形)图表?

[英]How to create a (bar) chart with two different scales for the Y axis using Google Chart Tools?

I would like to plot two sets of values on a bar chart, that have different scales. 我想在条形图上绘制两组具有不同比例的值。 For example, for each day of the week, I have a proportion (say the proportion of colleagues that were late that day) and a value (how late they were, on average). 例如,对于一周中的每一天,我都有一个比例(例如当天晚班的同事的比例)和一个值(他们平均晚到的时间)。

These two values can be plot on two separate charts, but it would be useful to have them on the same, for better comparison. 这两个值可以在两个单独的图表上绘制,但为了更好的比较,将它们放在同一个图表上会很有用。 The problem is that they don't have the same scale, thus it's not possible to use one common scale for the Y axis. 问题是它们没有相同的比例,因此不可能对Y轴使用一个公共比例。 The solution is to have two separate scales for the Y axis. 解决方案是对Y轴使用两个单独的比例尺。

Is it possible to do this using Google Chart Tools ? 是否可以使用Google Chart Tools执行此操作? I am using the JS api to generate interactive SVG charts, not the "still image" version. 我正在使用JS api生成交互式SVG图表,而不是“静止图像”版本。

This is possible with defining two axis: 这可以通过定义两个轴来实现:

 vAxis: {
     0: {
         viewWindow: {
             min: 0,
             max: 1000
         }
     },
     1: {
         viewWindow: {
             min: 0,
             max: 200
         }
     }
 }

This will plot the chart with two vertical axes, both with their own scale from min to max. 这将绘制带有两个垂直轴的图表,两个都有自己的刻度,从最小到最大。

I was not able to find a way, so I switched to HighCharts for my plots. 我找不到方法,所以我选择了HighCharts进行绘图。 It can handle multiple y axes: 它可以处理多个y轴:

http://www.highcharts.com/demo/combo-dual-axes http://www.highcharts.com/demo/combo-dual-axes

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

相关问题 无法在Google条形图中自定义其他Y轴 - Cannot customize different Y axis in Google bar chart 使用chart.js在两个y轴比例之间添加填充 - Add padding between two y-axis scales using chart.js 如何使用Chart.js-条形图和折线图固定角度图中X和Y轴的最大值和最小值 - How to fix maximum and minimum for X and Y axis in angular Chart using Chart.js - Bar and Line Chart 我可以使用Google图表工具创建重叠的条形图吗? - Can I create overlapping bar charts using Google Chart Tools? 使用 Chart.js 版本 3,如何左对齐堆积条形图上的 y 轴标签? - Using Chart.js version 3, How to left justify the y-axis labels on a stacked bar chart? Google 可视化双 Y 轴图表将线与特定条对齐 - Google visualization dual Y axis chart align line with specific bar 谷歌图表y轴定制 - Google chart y axis customization 如何使用带有0到100的y轴的chart.js创建Radar图表? - How do you create a Radar chart using chart.js with a y-axis of 0 to 100? 如何使用Chart JS在一张图中创建带有动态X和Y轴的多折线图? - How to create a multi line chart with with dynamic x and y axis in one graph using chart js? Chart.js - 如何在 x 轴和 y 轴之间创建不同的全局配置 - Chart.js - How to create a different global configuration between the x axis and the y axis
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM