Broken axis in Google charts
Asked Answered
R

2

6

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

Rearrange answered 21/1, 2013 at 11:47 Comment(0)
A
8

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.

Aronoff answered 23/1, 2013 at 4:19 Comment(3)
Love it, both really good alternatives that I hadn't even thought of, been too fixated on the breaking idea. CheersRearrange
It comes from working with Excel in its frustrating way to be able to do just about anything you want in the most roundabout ways. Let us know if you get it working! The hardest part will be coding the logic to find outliers...Aronoff
for the "cutting-off" part: that's done via options={ vAxis: { viewWindow: { max:500 } } }Tweezers
R
-1

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);
Remora answered 5/7, 2017 at 18:15 Comment(2)
Jeez, you really necro'd this question. Also downvoted because I specifically say in the question "a logarithmic scale is not an option"Rearrange
I understand your point, but, like me, many other people will arrive on this post by google search without define nothing about the exception specificated in the question. That situation turn useful my answer. Don't you think?Remora

© 2022 - 2024 — McMap. All rights reserved.