

Please take a look the below code snippet for the same. You can call getData.php service upon changing the year through dropdown and render the chart with data received from the service. x column is in timestamp, convert unixtimestamp(seconds) to javascript timestamp(milliseconds) by multipying the x value by 1000 Please refer for more informationĪrray_push($data_points, array("x"=> strtotime($row->x)*1000, "y"=> $row->y)) Įcho json_encode($data_points, JSON_NUMERIC_CHECK) That filter code means: If the current page is in the Edit or Add page, then filter the Products records which have the ProductCode only as the following: P-001, P-002, and P-003, otherwise display all products in the other pages (List and Search pages) which do not use the filter (represented by the empty string of filter in that code above). $result = $handle->fetchAll(\PDO::FETCH_OBJ) $handle->bindParam(":year",$_GET, PDO::PARAM_INT) $handle = $link->prepare("SELECT * FROM datapoints where YEAR(x) = :year order by x") \PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, $link = new \PDO( 'mysql:host=localhost dbname=canvasjs_db charset=utf8mb4', //'mysql:host=localhost dbname=canvasjs_db charset=utf8mb4', header('Content-Type: application/json') Please take a below code snippet for getData.php service. Creating a chart based on dropdown filter in php using data from database, you need to first create a php service getData.php which will provide data for any given year from database.
