如何禁用Google图表中的图例文字?

时间:2014-05-13 17:06:46

标签: google-visualization

如何在Google图表中禁用右侧的图例文字?它在这里用红色圈出来:

enter image description here

This is the chart I'm trying to use.这是我目前的代码:

<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>

1 个答案:

答案 0 :(得分:1)

请在此处查看“图例”选项的文档:https://developers.google.com/chart/interactive/docs/gallery/linechart

您想要添加

  legend: { position: "none" }

你的选择。