How to add multiple vertical axis on the same graph

123 views
Skip to first unread message

mrishadali

unread,
Jul 26, 2012, 5:33:11 PM7/26/12
to google-visua...@googlegroups.com
Hi, 
I'm using AreaCharts and LineCharts and I want to add multiple vertical axis for different values. Please see the attached image. 
Is there any way to do this kind of thing with viz api???
Thanks in advance

JFreeChart-time-series-line-graph-with-multiple-vertical-axes.PNG

asgallant

unread,
Jul 26, 2012, 6:01:48 PM7/26/12
to google-visua...@googlegroups.com
The API allows up to 2 vertical axes (1 left, 1 right).  Set the series.[seriesIndex].targetAxisIndex to 0 to assign a series to the left axis and to 1 to assign a series to the right axis.  Use the vAxes.[axisIndex] option to set the axis options (uses the same sub-options as vAxis).  Example:

var options {
    series{
        // assign the first series to the left axis
        0{
            targetAxisIndex0
        },
        // assign the second series to the right axis
        1{
            targetAxisIndex1
        }
    },
    vAxes{
        // assign options for the left axis
        0{
            title'Left Axis'
        },
        // assign options for the right axis
        1{
            title'Right Axis'

asgallant

unread,
Aug 22, 2012, 4:07:35 PM8/22/12
to google-visua...@googlegroups.com
When you use two vertical axes in the Visualization API, they will share common grid lines.  There is no way to add a third vertical axis, though, unless you use the AnnotatedTimeLine charts (warning: flash-based).  Support for more vAxes may come in the future, as the current release has a (very broken) method to add more - they just get drawn overlapping one another, so you can't read them.

On Wednesday, August 22, 2012 3:29:59 PM UTC-4, AddDry wrote:
Hi,

What I need is one set of grid lines and then the different axis apply their figures to the same lines - not like the picture from mrishadali where each axis has its own grid lines (albeit the lines don't run across the chart).

Imagine x is "amount earned" and c is "percentage earned used to pay gas bill" - see how there are only one set of grid lines and each series applies a figure to the grid lines.

£40    ___x___c___________
2.2%

£30    ___c_______c___x___
2.0%

£20    _______x___x___c___
1.8%

Ultimately I need 3 vertical axis (hence the post here) - is there any way of doing this?

Any ideas??

Cheers,
Adam
Reply all
Reply to author
Forward
0 new messages