More then 2 yAxes

98 views
Skip to first unread message

Tjeerd Kramer

unread,
Apr 5, 2012, 10:14:02 AM4/5/12
to Google Visualization API
Hi,

I am using a Combo chart to display 3 metrics, all with very different
ranges. I am capable of adding all 3 metrics to the graph, but the
only thing I can't get to work properly is the display position of the
yAxes scales.

Part of the code:

var options = {
series:{
0:{targetAxisIndex:0, lineWidth: 1, pointSize: 3},
1:{targetAxisIndex:1, lineWidth: 1, curveType: 'function',type:
"line"},
2:{targetAxisIndex:2, lineWidth: 1, color: 'grey'}
},
vAxes:{
0:{textStyle:{color: 'blue'}, title:'Turnover'},
1:{textStyle:{color: 'red'}, title:'CPA'},
2:{textStyle:{color: 'grey'}, title:'Profits'},
}
};

The problem here is that the scales for CPA and profits are written on
top of eachother. I'd like to be able to give them a margin and send
either one 100px to the right. Can this be achieved?

Many thanks

asgallant

unread,
Apr 5, 2012, 1:05:12 PM4/5/12
to google-visua...@googlegroups.com
As far as I am aware, the charts support a maximum of 2 vertical axes (with the exception of AnnotatedTimeline charts, which can support 3).

Tjeerd Kramer

unread,
Apr 10, 2012, 10:32:28 AM4/10/12
to Google Visualization API
Well, I have added 3:

var options = {
title: 'Average order value for "<? echo $city_name; ?>" at <? echo
$site_domain; ?>',
series:{
0:{targetAxisIndex:0, lineWidth: 1, pointSize: 3, type: "line"},
1:{targetAxisIndex:1, lineWidth: 1, pointSize: 3, curveType:
'function', type: "line"},
2:{targetAxisIndex:2, lineWidth: 1, color: 'grey'},
3:{targetAxisIndex:2, lineWidth: 1, color: 'orange', curveType:
'function', type: "line"}
},
vAxes:{
0:{minValue: 0, textStyle:{color: 'blue'}, title:'Turnover'},
1:{textStyle:{color: 'red'}, title:'Max CPA'},
2:{textStyle:{color: 'white'}, title:'Profits'},
}
};

And it all works as expected, except for the fact that the numbers on
the 3rd yAxis should move a little to the right.

asgallant

unread,
Apr 10, 2012, 11:57:04 AM4/10/12
to google-visua...@googlegroups.com
Like I said, the maximum number of supported y-axes is two.  The "third" axis is probably a bug.

Tjeerd Kramer

unread,
Apr 11, 2012, 2:43:22 AM4/11/12
to google-visua...@googlegroups.com
O.k., thanks. Where do I file a feature request? ;-)

asgallant

unread,
Apr 11, 2012, 9:06:37 AM4/11/12
to google-visua...@googlegroups.com

hanjar

unread,
May 8, 2012, 12:24:46 PM5/8/12
to google-visua...@googlegroups.com
hi,

original :
                        vAxes:{
                                0:{textStyle:{color: 'blue'}, title:'Turnover'},
                                1:{textStyle:{color: 'red'}, title:'CPA'},
                                2:{textStyle:{color: 'grey'}, title:'Profits'},
                        }

Convert it to  :

                        vAxes:{
                                0:{textStyle:{color: 'blue'}, title:'Turnover'},
                                1:{textStyle:{color: 'red'}, title:'CPA',textPosition: 'in'},
                                2:{textStyle:{color: 'grey'}, title:'Profits',textPosition: 'out'},
                        }

best regards,
hanjar
May combine with setting chart area width to expand the label/legend area

chartArea -> width:"80%"
Reply all
Reply to author
Forward
0 new messages