Home forums Using CanvasJS How can I use PHP MySQL Dynamic data Reply To: How can I use PHP MySQL Dynamic data



hi, i tried those example above but my chart didn’t render at all

this is my json

header(‘Content-Type: application/json’);


$element = $_POST[‘name’];
$year = $_POST[‘nama’];
$post = $_POST[‘name’] . $_POST[‘nama’];

include ‘koneksi.php’;

$data_points = array();

$query = mysql_query(“select nilai,tanggal from $post where bulan = 1 order by tanggal asc”);
while ($row = mysql_fetch_array($query)) {
$nila [$row[‘tanggal’]] = $row[‘nilai’];
$point = array(“x” => $row[‘tanggal’] , “y” => $row[‘nilai’]);
array_push($data_points, $point);

echo json_encode($data_points, JSON_NUMERIC_CHECK);
header( “refresh:5;url=chart.php” );

and it returns


and then it’s my html

<!DOCTYPE html>
<title>JSON test</title>
<script src=”jquery/jquery.js”></script>
<script src=”canvasjs.js”></script>
<script type=”text/javascript”>
$(document).ready(function () {

$.getJSON(“jsonparser.php”, function (result) {

var chart = new CanvasJS.Chart(“chartContainer”, {
data: [
{ type:’line’,
dataPoints: result

body test
<div id=”chartContainer” style=”width: 800px; height: 380px;”></div>


and its not rendering, is something missing or something wrong with my code???thank you in advance

  • This reply was modified 3 years, 4 months ago by  pratama.