hello everyone, my name is rizki,really need help,
i want to make candlestick from mysql and show it to the page
ihave one table named harga consist of id,open,low,close,high
this is the data.php to take the value from mysql
<?php
header(‘Content-Type: application/json’);
$con = mysqli_connect(“127.0.0.1″,”root”,””,”saham”);
// Check connection
if (mysqli_connect_errno($con))
{
echo “Failed to connect to DataBase: ” . mysqli_connect_error();
}else
{
$data_points = array();
$result = mysqli_query($con, “SELECT * FROM harga”);
while($row = mysqli_fetch_array($result))
{
$point = array(“x” => $row[‘tanggal’] , “y” => $row[‘open’],$row[‘low’],$row[‘high’],$row[‘close’]);
array_push($data_points, $point);
}
echo json_encode($data_points, JSON_NUMERIC_CHECK);
}
mysqli_close($con);
?>
and this is web page
<!DOCTYPE HTML>
<html>
<head>
<script type=”text/javascript”>
$(document).ready(function () {
$.getJSON(“data.php”, function (result) {
var chart = new CanvasJS.Chart(“chartContainer”, {
title: {
text: “Basic Candle Stick Chart”
},
zoomEnabled: true,
axisY: {
includeZero: false,
title: “Prices”,
prefix: “$ ”
},
axisX: {
interval: 2,
intervalType: “month”,
valueFormatString: “MMM-YY”,
},
data: [
{
type: “candlestick”,
dataPoints: result
}
]
});
chart.render();
}
</script>
<script src=”../../canvasjs.min.js”></script>
<title>CanvasJS Example</title>
</head>
<body>
<div id=”chartContainer” style=”height: 400px; width: 100%;”>
</div>
</body>
</html>
i am really stuck did not know what to do,really need help,thanks in advance