8

im using google api for line graph in my web application. in that line chart i dont want x axis line and y axis line, but i cant to fine how to remove the lines except the graph. could you please help me. i used this example for my practice

<script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart"]});
      google.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = google.visualization.arrayToDataTable([
          ['Year', 'Sales', 'Expenses'],
          ['2004',  1000,      400],
          ['2005',  1170,      460],
          ['2006',  660,       1120],
          ['2007',  1030,      540]
        ]);

        var options = {
          title: 'Company Performance'
        };

        var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
        chart.draw(data, options);
      }
    </script>
Hariprasath
  • 828
  • 4
  • 15
  • 41

2 Answers2

20

you cant remove or disable your x and y axis in google api the alter way is to set the baselineColor and gridlineColor same as the background color and set the textPosition to none.

vAxis:{
         baselineColor: '#fff',
         gridlineColor: '#fff',
         textPosition: 'none'
       }
Hariprasath
  • 828
  • 4
  • 15
  • 41
10

With the current version of Google Charts, the following removes axis lines:

hAxis: {
  baselineColor: 'none',
  ticks: []
},
vAxis: {
  baselineColor: 'none',
  ticks: []
}
nobody
  • 43
  • 1
  • 6
dkz
  • 921
  • 6
  • 10
  • 4
    I spent a while trying to figure out why this wasn't working, only to realise that the baseline for the hAxis is a vertical line and the baseline for the vAxis is a horizontal line. So if you want to remove the horizontal black line you need to set the vAxis `baselineColor` and vice-versa. – Chris Wheeler May 30 '17 at 16:26
  • This is perfect answer. Thanx a lot for help – Wraith Feb 25 '19 at 10:25
  • 1
    @ChrisWheeler 's comment provided the missing link for me. Thank you. – BodgeIT May 25 '19 at 09:19