Creating highchart linechart with data using PHP (and Laravel) -
Creating highchart linechart with data using PHP (and Laravel) -
i have dataset looks like:
month_name | intake_total | adoption_totals jan | 12 | 36 feb | 4 | 12 march | 23 | 46 apr | 45 | 89 may | 10 | 15 june | 15 | 20 july | 23 | 22 august | 23 | 45 september | 45 | 67 oct | 23 | 12 nov | 45 | 100 dec | 0 | 12
and trying create array show line chart
i have:
$chartarray["chart"] = array("type" => "line"); $chartarray["title"] = array("text" => "intakes vs. adoptions"); $chartarray["credits"] = array("enabled" => false); $chartarray["xaxis"] = array("categories" => array()); foreach ($results $result) { $categoryarray[] = $result->month_name; $chartarray["series"][] = array("name" => 'intake totals', "data" => array($result->intake_total)); $chartarray["series"][] = array("name" => 'adoption totals', "data" => array($result->adoption_total)); } $chartarray["xaxis"] = array("categories" => $categoryarray); $chartarray["yaxis"] = array("title" => array("text" => "number of pets")); homecoming $chartarray;
i know need populate info each series rows of each type can't figure out how that. ideas? thanks!
figured out. maybe help else:
$chartarray["chart"] = array("type" => "line"); $chartarray["title"] = array("text" => "intakes vs. adoptions"); $chartarray["credits"] = array("enabled" => false); $chartarray["xaxis"] = array("categories" => array()); foreach ($results $result) { $categoryarray[] = $result->month_name; } $intaketotal = []; $adoptiontotal = []; foreach($results $result){ array_push($intaketotal, $result->intake_total); array_push($adoptiontotal, $result->adoption_total); } $chartarray["series"][] = array("name" => 'intake totals', "data" =>$intaketotal); $chartarray["series"][] = array("name" => 'adoption totals', "data" => $adoptiontotal); $chartarray["xaxis"] = array("categories" => $categoryarray); $chartarray["yaxis"] = array("title" => array("text" => "number of pets")); homecoming $chartarray;
php laravel-4 highcharts
Comments
Post a Comment