Broken axis in Google charts

≡放荡痞女 提交于 2020-08-07 08:03:13

问题


Is there any way to create a break in my vertical scale on the Google charts api?

I have a couple of dozen data points all about 600-2000 on the y-axis except for one value which is almost 300,000; this makes all the smaller data points nearly unreadable. I need to represent all this data and a logarithmic scale is not an option.

Current Graph


回答1:


Simple answer: no, it is not possible.

Breaking axes is (generally) frowned upon in the visualization community and therefore isn't supported most of the time in various software.

If you want to be tricky, you can create a function to find outliers, and then move them to a second series in your data. Plot that series on the second axis, and have it with a different color. This says, "This figure is different and does not fit" which brings added attention to it, while still allowing the rest of the data to be seen in the same scale.

Personally I would just cut off the graph at an arbitrary value, set the value of that point to the maximum value, and add a tooltip saying, "Outlier: 300,000" or whatever it is. This will allow people to see the other numbers, but show that this number itself is an outlier without coloring it differently or removing it from the single series.

Either way is doable.




回答2:


You need use a log scale. It's a vAxis and hAxis attribute. The supported values are:

log: Conventional logarithm scale

mirrorLog: Logarithm scale that allows 0 values

var options = {
    vAxis: {
        scaleType: 'mirrorLog',
    }
};

var data = {};//your data

chart.draw(data, options);


来源:https://stackoverflow.com/questions/14437955/broken-axis-in-google-charts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!