【问题标题】:Google charts legend customize谷歌图表图例自定义
【发布时间】:2016-08-11 10:22:21
【问题描述】:

我有两个系列/列fileSizeoutput Target

是否有可能在图例中只显示output Target而隐藏fileSize

【问题讨论】:

    标签: google-visualization customization legend


    【解决方案1】:

    你可以使用visibleInLegendconfiguration option

    只分配给序列号

    请参阅以下工作 sn-p...

    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>

    【讨论】:

    • 非常感谢。这就是我一直在寻找的。​​span>
    猜你喜欢
    • 2016-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多