Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

156
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda