Ok, I did it. With getdata.php:
$return = array();
while ($row = pg_fetch_array($result)) { 
    $return[] = array((int)$row[0],(int)$row[1]);
} 

pg_close($db); 

//var_dump($return);       
echo $data = json_encode($return);

I get:

[[6,4],[6,5],[7,6],[9,8],[5,9]]


and I use in index.php


<?php include 'getData2.php'; echo '$data'; ?>
 with

data.addRows(<?php echo ($data)?>);
 It turns out that is some problem with php inside html on IIS server.


index.php in browser

<!DOCTYPE HTML>

<head>

<script 
src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js";></script>
 <script type="text/javascript" 
src="https://www.gstatic.com/charts/loader.js";></script>
  <script type="text/javascript" src="https://www.google.com/jsapi";></script>
  <script type="text/javascript">
    google.charts.load('current', {packages: ['corechart', 'line']});
    google.charts.setOnLoadCallback(drawChart);
      


    function drawChart() {
//here is my php include getData2.php echo data...
        [[6,4],[6,5],[7,6],[9,8],[5,9]]


$data     
      var data = new google.visualization.DataTable();
      data.addColumn('number', 'ph');
      data.addColumn('number', 'broj');
      
    //here read php echo
        data.addRows([[6,4],[6,5],[7,6],[9,8],[5,9]]);
   
        var options = {
       
        width: 1000, height: 300,
        
        hAxis: {
          title:'datum'
        },
        vAxis: {
            title: 'pH'
        },
        };


      var chart = new 
google.visualization.AreaChart(document.getElementById('chart_div'));
      chart.draw(data, options);
    }
    </script>
  </head>

  <body>
  
    <!--Div that will hold the pie chart-->
    <div id="text">graf</div>
    <div id="chart_div"></div>
  </body>
</html>






Dana srijeda, 25. listopada 2017. u 14:07:00 UTC+2, korisnik Daniel 
LaLiberte napisao je:
>
> You should read the documentation at 
> https://developers.google.com/chart/interactive/docs/datatables_dataviews
> Note that the way you use JSON makes a difference.  What you are doing 
> would make sense, but it is not supported.
>
> You should probably just use the simpler array of arrays form, so generate 
> JSON like this instead:
>
> [[6, 4], [6, 5}, ...]
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/9d2cf4fc-04a9-4292-a750-917c8169b82c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to