0
Hello Friends Programmers I am in need of a help.
I’m trying to generate a chart with Google Chats of schedules per month, but in the database the saved dates are in the xx/xx/xxxx format. I wonder if anyone can help me so that I can put the months statically or dynamically if converting all the dates into months in full and the amount on the chart.
<html>
<head>
  <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([
        ['Meses', 'Agendamentos'],
    <?php
    include('connection.php');
    $query = mysqli_query($conn, "SELECT COUNT(agend_id) AS qtd FROM agendamento GROUP BY MONTH(agend_data)");
    $meses = [];
    while ($dados = mysqli_fetch_array($query)) {
        $mes = array_push($meses, "Janeiro", "Fevereiro", "Março", "Abril");
        $qtd = $dados['qtd'];
    ?>
      ['<?php print_r($mes); ?>', <?php echo $qtd; ?>],
    <?php } ?>
  ]);
  var options = {
    title: 'Company Performance',
    curveType: 'function',
    legend: {
      position: 'bottom'
    }
  };
  var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));
  chart.draw(data, options);
}
 </script>
</head>
<body>
  <div id="curve_chart" style="width: 900px; height: 500px"></div>
</body>
</html>
The graph above is that you can generate but only missing the months on the X of the chart.
I thank you in advance for any kind of help.


you can form the date to the format you want using the functions of the
mysql, take a look at the documentation ofDATE_FORMAT– Ricardo Pontual
Ricardo would have how to show how it would look in this query context?
– Emmanuel Siqueira