Question

How can I disable the legend text on the right in a Google chart? It's circled in red here:

enter image description here

This is the chart I'm trying to use. Here is my current code:

<html>
  <head>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart"]});
      google.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = google.visualization.arrayToDataTable([
          ['Year', 'Sales', 'Expenses'],
          ['2013',  1000,      400],
          ['2014',  1170,      460],
          ['2015',  660,       1120],
          ['2016',  1030,      540]
        ]);

        var options = {
          title: 'Company Performance',
          hAxis: {title: 'Year',  titleTextStyle: {color: '#333'}},
          vAxis: {minValue: 0}
        };

        var chart = new google.visualization.AreaChart(document.getElementById('chart_div'));
        chart.draw(data, options);
      }
    </script>
  </head>
  <body>
    <div id="chart_div" style="width: 900px; height: 500px;"></div>
  </body>
</html>
Was it helpful?

Solution

See the docs for the 'legend' options here: https://developers.google.com/chart/interactive/docs/gallery/linechart

You want to add

  legend: { position: "none" }

to your options.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top