I'm sure I'm just missing something from a procedure standpoint, but I'm looking for some assistance in formatting the array string for a Stacked Column, where all data is derived from MySQL.
I've verified that my query is returning all the correct results and I can echo them all out independently....I just can't figure out the correct order to build the array to render the chart.
Here's what I've got so far:
$categoryArray=array();
$seriesnameArray=array();
$seriesdataArray=array();
while($row = mysqli_fetch_array($result)) {
array_push($categoryArray, array(
"label" => "YTD"
)
);
array_push($seriesnameArray, array(
$row["buying_channel"],
"value" => $row["pct_of_incidents"]
)
);
//array_push($seriesdataArray, array(
// "value" => $row["pct_of_incidents"]
// )
// );
// }
$arrData["categories"]=array(array("category"=>$categoryArray));
$arrData["dataset"]=array(array("seriesname"=>$seriesnameArray));
// $arrData["data"]= array(array($seriesdataArray));
This produces the following array:
"data":[],"categories":[{"category":[{"label":"YTD"},{"label":"YTD"},{"label":"YTD"},{"label":"YTD"},{"label":"YTD"}]}],"dataset":[{"seriesname":[{"0":"In Club","value":"0.5192"},{"0":"Online","value":"0.4338"},{"0":"Transfer","value":"0.0263"},{"0":"Auction","value":"0.0117"},{"0":"Social Media","value":"0.0091"}]}]}
What I can't figure out is how to insert the "Data[]" attribute for each seriesname. Currently it's producing a "0" value for each entry and I can't figure out where it's derived from.
Any insight would be greatly appreciated!
Thanks!