2

I have a simple Google area chart with only one series and 2 columns - Date and Money. The only problem is when all the values in the "Money" column are 0, 1 or 2. Then, duplicate values in the vertical axes appear.

For example when all the values are 0, the vAxis is:

1

1

0

When all the values are 1, the vAxis is:

1

1

1

0

0

It's really strange and I don't know what am I missing and I couldn't find anywhere the same problem.

The API is loaded like that:

google.load('visualization', '1.0', {packages: ['corechart'], 'callback':drawVisualization});

The data of the chart is this for example:

  var data = new google.visualization.DataTable();
  data.addColumn('string','Date');
  data.addColumn('number', 'Money');
  data.addRows([
     ['March 1',  0],
     ['March 2',  0],
     ['March 3',  0],
     ['March 4',  0]
  ]);

The code for the creation of the chart is this:

ac.draw(data, {
  chartArea: {width: '90%', height: '80%'},
  legend: {position: 'none'},         
  colors:['#24b3b0'],
  isStacked:false,
  pointSize: 10,
  width: 938,
  height: 400,
  areaOpacity: 0.2,
  hAxis:{
    showTextEvery:7,
    maxAlternation:1,
    maxTextLines:1
  },
  vAxis:{
     viewWindowMode:'explicit',
     viewWindow:{
          min:0
     },
     format:'$###,###,###',
     gridlines:{
        color:'#ccc' 
     },
     baselineColor:'#cfcfcf'
  }
});

I'm using viewWindow.min to set the minimum value of vAxis, because vAxis.minValue had no effect as described in this question: Setting a hard minimum axis value in Google Charts API

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • I found the problem. It's just that in case all values are zero the vAxis is: 1, 0.5, 0. But due to the vAxis.format:'$###,###,###' 0.5 becomes 1. – Hristo Hristov Aug 18 '12 at 17:00

0 Answers0