M.Dagiya
M.Dagiya

Reputation: 203

secondary axis title in Google chart's comboChart not working

                chart.draw(data,{
                    colors:[self.model.get("color"), '#FF0000'],
                    height: 600,
                    title: self.model.get("title"),
                    chartArea: { width:'80%',height:'80%'},
                    legend: {position: 'bottom'},
                    animation:{
                        startup: true,
                        duration: 500,
                        easing: 'inAndOut',
                    },
                    vAxis:{
                    0:{
                            title:self.model.get("x_axis_label")
                        },
                    1:{
                            title:"Temperature"
                        }
                    },
                    hAxis:{
                        title:self.model.get("x_axis_label"),
                        slantedText: false,
                        slantedTextAngle: 0
                    },
                    series:
                    {
                        0: {
                            type:'bars',
                            targetAxisIndex:0
                        },
                        1: {
                            type:'line',
                            targetAxisIndex:1
                        }
                    }
                });

I have two vertical Axis(Temperature and KWh). Every thing works except the title of vertical axis are not shown on the chart. I have defined vAxis in the options and targetAxisIndex inside series. I searched google and could not find anything except that vAxis should have 0:{} and 1:{} for two vertical axis.

enter image description here

Upvotes: 4

Views: 1603

Answers (1)

WhiteHat
WhiteHat

Reputation: 61275

when using multiple y-axis, need to use --> vAxes -- with an e -- not vAxis

This property can be either an object {} or an array []

object...

vAxes: {
  0: {
    title: self.model.get("x_axis_label")
  },
  1: {
    title: "Temperature"
  }
},

array...

vAxes: [
  {
    title: self.model.get("x_axis_label")
  },
  {
    title: "Temperature"
  }
],

Upvotes: 5

Related Questions