Home Forums Chart Support How to populate data from PHP, MYSQL to Multi Series Line Graph

How to populate data from PHP, MYSQL to Multi Series Line Graph

Viewing 2 posts - 1 through 2 (of 2 total)
  • #9935

    Hi Sunil,
    based on my JSON data from MySQL below: how can i display into in multi series line charts.
    – The report_date will be in x axis
    – submited,pending,approved,declined will be displayed in four different lines.
    – each labels will be display on each line.

    [
       {
         “report_date”:”2016-02-02″,
         “submited”:1,
         “approved”:”1″,
         “declined”:”0″
       },
       {
          “report_date”:”2016-02-03″,
          “submited”:2,
          “approved”:”0″,
          “declined”:”1″
      },
      {
          “report_date”:”2016-02-17″,
          “submited”:1,
          “approved”:”0″,
          “declined”:”0″
       }
    ]

    When i do below, i only get one line. which is only ‘submitted’ line.

    $result= getReportStatistic($startDate,$endDate);
         $data_points = array();
            foreach($result as $row){
                $point = array(“label”=>$row[‘report_date’],”y”=>$row[‘submited’]);
                array_push($data_points, $point);
            }
    echo json_encode($data$data_points, JSON_NUMERIC_CHECK);
    

    //AJAX

    success: function(data){
            var result = $.parseJSON(data);
            var columnchart = new CanvasJS.Chart(“chartContainer”, {
                title:{
                      text: “Overall report statistic”
                },
                axisX:{
                     gridColor: “Silver”,
                     tickColor: “silver”,
                     valueFormatString: “DD/MMM”
                },
                 data: result
             });
             columnchart.render();
           }
    

    Really Appreciated for your help.
    Best Regards,
    Elvis Ximenes

    • This topic was modified 8 years, 8 months ago by elvisximenes.
    • This topic was modified 8 years, 8 months ago by elvisximenes.
    • This topic was modified 8 years, 8 months ago by elvisximenes.
    #9944

    Hi Elvisximenes,

    You can format your json data across multiple series as shown in this example

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.