bondus
bondus

Reputation: 119

Google line chart y axis appear 2 times (doubled)

I am using google line chart to draw a line chart.If the data used to draw the chart has only one value, as shown in the image, on the vaxis of the chart appear the axis 1 for 2 times and I don't want this.I would like the vaxis to be normal, only with one time axis number. The code used for vaxis is:

vAxis: 
{
    format: '#',
    minValue: 0,
    gridlines: {
    count: 4
}

The chart is: drawn chart

Any response is appreciated

Upvotes: 1

Views: 211

Answers (1)

WhiteHat
WhiteHat

Reputation: 61222

Set vAxis.ticks to an array containing the tick marks needed.
The array could also be built dynamically from the data...

google.charts.load('44', {
  callback: drawChart,
  packages: ['corechart']
});

function drawChart() {
  var data = new google.visualization.DataTable({
    cols: [
      {id: '', label: 'Month', type: 'string'},
      {id: '', label: 'Downloads', type: 'number'},
      {id: '', role: 'annotation', type: 'string'}
    ],
    rows: [
      {c:[{v: 'February'}, {v: 1}, {v: '1'}]}
    ]
  });

  var options = {
    vAxis: {
      format: '#',
      minValue: 0,
      ticks: [0, 1, 2]
    }
  };

  var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
  chart.draw(data, options);
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>

Upvotes: 1

Related Questions