TheDoctor
TheDoctor

Reputation: 2512

Google charts legend customize

I have two series/columns fileSize and output Target.

Is it possible two display only output Target in the legend and hide fileSize?

Upvotes: 0

Views: 3125

Answers (1)

WhiteHat
WhiteHat

Reputation: 61212

you can use the visibleInLegend configuration option

just assign to the series number

see following working snippet...

google.charts.load('current', {
  callback: function () {
    var data = google.visualization.arrayToDataTable([
      ['File', 'fileSize', 'output Target'],
      ['a', 10, 15],
      ['b', 12, 18],
      ['c', 14, 21],
      ['d', 16, 24]
    ]);

    var container = document.getElementById('chart_div');
    var chart = new google.visualization.ColumnChart(container);

    chart.draw(data, {
      legend: {
        position: 'bottom'
      },
      series: {
        0: {
          visibleInLegend: false
        }
      }
    });
  },
  packages: ['corechart']
});
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>

Upvotes: 1

Related Questions