I don“t know how to make available the variable json with data generated by php in the javascript/html code. I supose that if I generate if via php , the data must be available for code. It is not happeging. This is the sintaxe error in the javascript.
Tks Eriovaldo Em sexta-feira, 1 de junho de 2018 11:47:01 UTC-3, Eriovaldo Andrietta escreveu: > > Why this code is not working fine ? > I have the php code that generates do jsontable but I cannot use it in the > html? > Any idea ? > > <html> > <head> > <script type="text/javascript" src=" > https://www.gstatic.com/charts/loader.js"></script> > <script type="text/javascript" src="// > ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> > <script type="text/javascript"> > google.charts.load('current', {'packages':['corechart']}); > google.charts.setOnLoadCallback(drawChart); > function drawChart() > { > var data = new google.visualization.DataTable(<?php > $conn = oci_connect('eri', 'senha123', 'localhost/orcl'); > if (!$conn) { > $erro = oci_error(); > trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); > } > $query = oci_parse($conn, "select tipo, tempo from eri"); > oci_execute($query); > $rows = array(); > $table = array(); > $table['cols'] = array( > array('label' => 'tipo', 'type' => 'string'), > array('label' => 'tempo', 'type' => 'int'), > ); > $rows = array(); > while($r = oci_fetch_array($query, OCI_ASSOC+OCI_RETURN_NULLS)) { > $temp = array(); > $temp[] = array('v' => (string) $r['TIPO']); > $temp[] = array('v' => (int) $r['TEMPO']); > $rows[] = array('c' => $temp); > } > $table['rows'] = $rows; > $jsontable = json_encode($table); > echo $jsontable; > ?> > ); > > var options = { > title:'Sensors Data', > legend:{position:'bottom'}, > chartArea:{width:'95%', height:'65%'} > }; > > var chart = new > google.visualization.LineChart(document.getElementById('line_chart')); > chart.draw(data, options); > } > </script> > <style> > .page-wrapper > { > width:1000px; > margin:0 auto; > } > </style> > </head> > <body> > <div class="page-wrapper"> > <br /> > <h2 align="center">SHOW 1 - Display Google Line Chart with JSON PHP & > Oracle </h2> > <div id="line_chart" style="width: 100%; height: 500px"></div> > </div> > </body> > </html> > -- 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/10ef32c6-1c0c-412c-9ea7-c02d60c4b073%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
