I use the following PHP lines to convert some simpleXML data to an array:
$dataRaw = array();
foreach($objCount->escalations as $esc) {
$dataRaw[(string)$esc->region] = (int)$esc->volume;
}
$dataPrep = json_decode(json_encode($dataRaw), TRUE);
Printing this returns the following which looks ok to me:
Array ( [af] => 6 [as] => 295 [eu] => 249 [na] => 279 [oc] => 42 [sa] => 10 )
I then tried to pass this in a JS function using the following line but this doesn't work. I am not getting any errors, the chart just doesnt show at all with this, probably because it doesn't recognise the content.
data: <?php echo $dataPrep;?>
When I hard-code the "data" values in JS as follows then everything works fine so I am probably passing it wrong.
var data = [{ 'hc-key': 'af', value: 6 },
{ 'hc-key': 'as', value: 295 },
{ 'hc-key': 'eu', value: 249 },
{ 'hc-key': 'na', value: 279 },
{ 'hc-key': 'oc', value: 42 },
{ 'hc-key': 'sa', value: 10 }];
Can some tell me what I have to change here ?
Many thanks in advance, Tim.