Thank you very much for your reply to my inquiry and your offer of help Mohan.
i try use post to send start and end date user select to php page to get date from database base date user selected:
var startDate = picker.startDate.format(‘YYYY-MM-DD’);
var endDate = picker.endDate.format(‘YYYY-MM-DD’);
// alert(startDate = ${startDate}, endDate = ${endDate}
);
$.ajax({
url : 'chart.php',
type : 'POST',
data : {startDate:startDate,endDate:endDate},
success : function(data) {
$.getJSON("chart.php", function (data) {
var chart = new CanvasJS.Chart("chartContainer", {
data: [
{
indexLabel: " {y}",
indexLabelFontSize: 16,
dataPoints: data
}
]
});
chart.render();
});
}
});
But the chart does not appear.
this php code :
include("config.php");
if (isset($_POST['startDate'])) {
$startDate = $_POST['startDate'];
$endDate = $_POST['endDate'];
//echo $startDate;
$data_points = array();
$result = mysqli_query($con, "SELECT sub, main, SUM(amount) AS total FROM data WHERE payment_date BETWEEN '$startDate' AND '$endDate' GROUP BY sub, main order by total desc LIMIT 15");
while($row = mysqli_fetch_array($result))
{
$point = array("label" => $row['sub'] , "y" => $row['total']);
array_push($data_points, $point);
}
echo json_encode($data_points, JSON_NUMERIC_CHECK);
}