Double Y axis - not being able to adjust targetAxisIndex

109 views
Skip to first unread message

Chris

unread,
Dec 10, 2015, 11:18:08 AM12/10/15
to Google Visualization API
I am creating a multiple line chart with Google Chart API where I want to use 2 Y axis such as -> [![enter image description here][1]][1], but with one axis set to max 24000 for my 6 countries, and the second set to 90000 for the 'Total World' column. 

The problem is that my set of options never returns the 'Total World' in the second y axis and the other 6 countries in the first y axis, no matter how I arrange the option 'targetAxisIndex':

   
var tot = 95000;
   
var min = 0, var max = 24000;
   
....


     
var options = {
                title
: 'Top Consuming Nations - Thousand barrels daily',
               
                hAxis
: {title: 'Year'},
                width
: 1050, height : 400,
               
                vAxes
: [
                 
{title: 'Top Countries', titleTextStyle: {color: '#FF0000'},  maxValue: max},  // Left axis maxValue: 60000
                 
{title: 'Total World', titleTextStyle: {color: '#FF0000'},  maxValue: tot}  // Right
               
],
                series
:[
                 
{targetAxisIndex:1},
                 
{targetAxisIndex:0}
               
],
                legend
: { position: 'top', alignment: 'start' }
             
};






Sergey Grabkovsky

unread,
Dec 10, 2015, 11:25:25 AM12/10/15
to Google Visualization API
Hi Chris,

The series option is supposed to be a mapping of series index to series options. When you specify it as an array, you're basically doing that assignment implicitly. So in your example, series 0 will go on axis 1, and series 1 will go on axis 0. All other series will go to the default axis (0). Your issue could be fixed pretty easily, by simply reorganizing your series such that the total is the first series. Alternatively, you could explicitly specify that series 6 (your total series, 'country6') should go on axis 1. The default is for things to go on axis 0, so you don't need to explicitly specify that. Here's an updated version of your plunkr with the second version of the solution (since that was easier for me to do): http://plnkr.co/edit/GhsNcBCtDW0i4OTu0VJR?p=preview

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/561415e4-f12c-4b01-b7c3-94064fb5c954%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--

unnamed.gif

Sergey Grabkovsky

Software Engineer

Google, Inc

gra...@google.com

Reply all
Reply to author
Forward
0 new messages