Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
Google Charts Visualization with Legend
<!DOCTYPE html>
<html>
  <head>

    <p>
        
    </p>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">
      google.charts.load('current', {'packages':['corechart']});
      google.charts.setOnLoadCallback(drawChart);

      function drawChart() {
        var data = google.visualization.arrayToDataTable([
        ['Year', 'BirthRate', 'AgeGroup'],  


        <?php
            

        while ($row = mysqli_fetch_array($result))


         {
          //echo "[".$row["Year"].",". $row["BirthRate"]."],";
            echo "[".$row["Year"].",". $row["BirthRate"] .",".$row["AgeGroup"]."],";

        }

        ?>

        ]);

      var options = {

        title: 'Year by BirthRate',
        hAxis: {title: 'Year', minValue: 1940, maxValue: 2000},
        vAxis: {title: 'BirthRate', minValue: 0, maxValue: 275},
        colors: ['#a52714', '#097138'],
        legend: 'AgeGroup'
      };

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

        chart.draw(data, options);
      }
    </script>
  </head>
  <body>
    <div id="chart_div" style="width: 900px; height: 500px;"></div>
  </body>
</html>

Trying to make a google chart visualization depicting Year by Birth Rate with a legend/key for Age Group. I get errors that do not allow me to do this like SyntaxError: Unexpected identifier 'years'. Expected either a closing ']' or a ',' following an array element.I attached an image that shows what my database looks like

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!