Graph with Google Charts [closed]

0

How can I fill out this graph with MySQL data?

<?php
$sql = 'SELECT * FROM historicos';
$resultado = mysqli_query($conn, $sql); 
?>
<script type="text/javascript">
  google.charts.load('current', {'packages':['corechart']});
  google.charts.setOnLoadCallback(drawChart);

  function drawChart() {
    var data = google.visualization.arrayToDataTable([
      ['Horario', 'Sales'],
      ['2004',  0.500],
      ['2005',  0.1],
      ['2006',  0.200],
      ['2007',  0.30]
    ]);

    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>

After some adjustments worked .. ' function drawChart () {                             var data = google.visualization.arrayToDataTable ([                                 ['Schedule', 'Response time'],                                                                  ]);

'

    
asked by anonymous 06.09.2016 / 16:55

1 answer

0

just replace

function drawChart() {
var data = google.visualization.arrayToDataTable([
  ['Horario', 'Sales'],
  ['2004',  0.500],
  ['2005',  0.1],
  ['2006',  0.200],
  ['2007',  0.30]
]);

for something like this

function drawChart() {
var data = google.visualization.arrayToDataTable([
  ['Horario', 'Sales'],
  <?php 
    $sql="sua query";
    $query=mysqli_query($con,$sql);
    while($result=mysqli_fetch_array($query,MYSQLI_ASSOC)){
      echo "['".$result['campo1']."', '.$result['campo2']."'],";
    }
  ?>
]);

Clear this in a php file

    
06.09.2016 / 17:02