在Google图表上停用或隐藏图例

时间:2016-03-01 20:52:01

标签: php charts

我有一个谷歌图表从我的数据库中拖动信息。我不需要图表上的图例,现在只是一个蓝色方块,在我的图表的上角没有文字,看起来不太好,下面是我的图表代码,我也附上了输出的截图。隐藏或删除它的任何帮助都会很棒。

    echo "  <script>

        google.charts.load('current', {packages: ['corechart', 'bar']});
    google.charts.setOnLoadCallback(drawMultSeries);

    function drawMultSeries() {
          var data = new google.visualization.DataTable();
          data.addColumn('timeofday', 'Time of Day');
          data.addColumn('number', 'Motivation Level');
          data.addColumn('number', 'Energy Level');
    var data = google.visualization.arrayToDataTable([
             ['', '', { role: 'style', position: 'hidden' }],

             ['Brookfield',"; echo $Brookfield;

             echo ", 'yellow'],            // RGB value
             ['CUH',"; echo $CUH;

             echo ", 'red'],            // English color name
             ['Boole', ";
             echo $Boole;
             echo ", 'blue'],


          ]);


          var options = {
            title: 'Current Levels of the UCC Libraries',
            hAxis: {
              title: 'Library Location',
              format: 'h:mm a',
              viewWindow: {
                min: [7, 30, 0],
                max: [17, 30, 0]
              }
            },
            vAxis: {
              title: 'Capacity (% of 100)'
            }
          };

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

          chart.draw(data, options);
        }


</script>";

请看这个截图: enter image description here

1 个答案:

答案 0 :(得分:0)

好的,在Noam Hacker的帮助下,通过编辑var选项来获得...

     var options = {
            legend: 'none',
            title: 'Current Levels of the UCC Library',
            hAxis: {
              title: 'Library Location',
              format: 'h:mm a',
              viewWindow: {
                min: [7, 30, 0],
                max: [17, 30, 0]
              }
            },
            vAxis: {
              title: 'Capacity (% of 100)'
            }
          };