Thank you Daniel, it works! Il giorno lunedì 1 maggio 2017 17:41:15 UTC+2, Giuseppe Ricci ha scritto: > > Hi, > > I'm new with Google Chart. I'm retrieving with PHP weather data from > OpenWeather API. > I pass to javascript the 2 data arrays with dates and temperatures to > build a data array used to the google chart. > My code is: > > <script type="text/javascript"> > var temp=new Array(); > <?php > for($i=0;$i<count($temperature);$i++){?> > temp[<?php echo $i; ?>]="<?php echo "$temperature[$i]"; ?>"; > <?php > }?> > > var dataora=new Array(); > <?php > for($i=0;$i<count($dataora);$i++){ > ?> > dataora[<?php echo $i; ?>]="<?php echo "$dataora[$i]"; ?>"; > <?php > }?> > > google.charts.load('current', {'packages':['line']}); > google.charts.setOnLoadCallback(drawChart); > > function drawChart() { > var data2 = new Array(); > > data2[0] = [ 'Date', 'Temperature' ]; > for (i = 0; i < temp.length; i++) { > data2[i + 1] = [ dataora[i], parseFloat(temp[i]) ]; > } > var data = google.visualization.arrayToDataTable(data2, > false); > > document.write(JSON.stringify(data)); > > var options = { > chart: { > title: 'Previsioni Temperatura', > subtitle: 'in °C' > }, > width: 1000, > height: 500, > > } > }; > > var chart = new > google.charts.Line(document.getElementById('chart_div')); > chart.draw(data, google.charts.Line.convertOptions(options)); > } > > </script> > > <div id="chart_div" style="50%"></div> > > Opening the console I see this error: > > Uncaught Error: Container is not defined > > Can someone help me to solve this error? > Thanks. >
-- You received this message because you are subscribed to the Google Groups "Google Chart API" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-chart-api+unsubscr...@googlegroups.com. To post to this group, send email to google-chart-api@googlegroups.com. Visit this group at https://groups.google.com/group/google-chart-api. For more options, visit https://groups.google.com/d/optout.