why highchartis giving different results with similar data structure?

I am using high chart in my yii based application.

after querying the database I am storing the result in a associative array named $catexp

after printing the structure using print_r($catexp) I am getting follwing


Array ( [0] => Array ( [name] => Food [y] => 91 ) [1] => Array ( [name] => Utilities [y] => 9 ) )

now this the structure of data which can be passed to highcart for generating pie chart.

but after passing this $catexp as data for pie chart I am getting wired output i.e. i am not getting the full chart

see the attachment for image…

2147

Capture.JPG

although i made a similar manual array structure like this


$a = array('name'=> 'Opera','y'=>91);

        $b = array('name'=> 'Safari','y'=>9);

    	$c = array($a,$<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='B)' />;

print_r($c) gives


Array ( [0] => Array ( [name] => Opera [y] => 91 ) [1] => Array ( [name] => Safari [y] => 9 ) )

and passed this variable as data for pie chart and i got the full chart.

see the attacment…

2148

Capture1.JPG

So my question is what is wrong with my previous chart both the array structures are same but output is diff?????

finally i found the bug why i am not getting the full data… it is because the $catexp array contain the ‘y’ value in string format which should be number and because of this i was getting error so i used a foreach loop and converted the ‘y’ values to double like




$i = 0;

foreach ($catexp as $key => $value)

{

$c[]=array($catexp[i]['name'], (double)$catexp[i]['y']);

}



and then i am passing $c as data to piechart and i am getting desired output.

hope somw day it will help you…

Thanks Rahul

That was really helpful :) Thanks a Tonnn