0

I have a google chart dragging information from my database. I have no need for the legend on the chart and is now just a blue square with no text in the top corner of my chart and doesn't look good, below is my chart code and I have attached a screenshot of the output also. Any help to hide or remove it would be great.

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

please see this screenshot: enter image description here

Noam Hacker
  • 4,671
  • 7
  • 34
  • 55
dhool
  • 291
  • 1
  • 3
  • 14
  • [see here for similar question](http://stackoverflow.com/questions/5202029/hiding-the-legend-in-google-chart) – Noam Hacker Mar 01 '16 at 21:03
  • i checked that out but im wondering where to put the legend:(position: hidden) as there is and I have no css for the chart? – dhool Mar 01 '16 at 21:11
  • try it in the `options`? – Noam Hacker Mar 01 '16 at 21:13
  • see the first comment on [this answer](http://stackoverflow.com/a/9068972/4926817) – Noam Hacker Mar 01 '16 at 21:15
  • so as i understand it the legend option should be like {legend:{position:'none'}}; but everytime i try to put it in the chart disappears, could you show me how to fit it in correctly? – dhool Mar 01 '16 at 21:19
  • unfortunately I've never done this before, you might have to play around with the syntax until you find something that works. another answer suggested `legend: 'none'` – Noam Hacker Mar 01 '16 at 21:23

1 Answers1

1

Ok so got with the help of Noam Hacker by editing the var options to this...

     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)'
            }
          };
dhool
  • 291
  • 1
  • 3
  • 14