Questo è il codice che ho provato...ovviamente vediti bene la libreria chart.js, visto che è laprima volta che ne sento parlare![]()
codice:<html> <head> <script src="http://code.jquery.com/jquery-latest.min.js"></script> <!-- credo che dovresti scaricarti lo script dal sito --> <script src="https://raw.githubusercontent.com/nnnick/Chart.js/v2.0-dev/dist/Chart.js"></script> <script> $(window).load(function () { var ctx = document.getElementById('canvas'); $.ajax({ type: 'GET', dataType: 'json', url: 'test.php', success: function(response){ if(response){ var labels = []; var data = []; $.each(response, function(index, value){ labels.push(value.label); data.push(value.data); }); var chart = new Chart(ctx, { type: 'bar', data: { labels: labels, datasets: [{ data: data }] } }); } }, error: function(xhr, ajaxOptions, thrownError){ alert(thrownError); }, complete: function(){ } }); }); </script> </head> <body> <canvas id="canvas" width="400" height="400"></canvas> </body> </html>

Rispondi quotando