Dear Group! I have a php code with a google chart. I've try everything but it doesn't work for me. I have two variable: Date: format like: '2024-01-23 14:36:43' Value: format like: '234'. This values come from mysql.
The error code is: Uncaught SyntaxError: missing ) after argument list (at index.php:17:33) Thanks for your help and advice! H.Laszlo https://developers.google.com/chart/interactive/docs/datesandtimes <?php $connection = mysqli_connect('localhost', 'xxxx', 'xxxx', 'database'); $result = mysqli_query($connection, "SELECT id, date, value FROM table"); ?> <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 = new google.visualization.DataTable(); data.addColumn('date', 'Time of Day'); data.addColumn('number', 'Rating'); data.addRows([ <?php if(mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_array($result)) { $datum = $row['date']; $ertek = $row['value']; ?> [new Date( <?php echo $row['date']; ?> ), <?php echo $row['value']; ?> ], <?php } } ?> ]); var options = { title: 'Rate the Day on a Scale of 1 to 10', width: 900, height: 500, hAxis: { format: 'Y/m/d h:m:s', gridlines: {count: 15} }, vAxis: { gridlines: {color: 'none'}, minValue: 0 } }; var chart = new google.visualization.LineChart(document.getElementById('chart_div')); chart.draw(data, options); var button = document.getElementById('change'); button.onclick = function () { // If the format option matches, change it to the new option, // if not, reset it to the original format. options.hAxis.format === 'M/d/yy' ? options.hAxis.format = 'MMM dd, yyyy' : options.hAxis.format = 'M/d/yy'; chart.draw(data, options); }; } </script> </head> <body> <div id="chart_div"></div> </body> </html> -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/google-chart-api/ee192f27-8814-446d-ab19-579aadcf41c5n%40googlegroups.com.
