I'm trying to build a chart with this module with the open flash charts API where the x_labels and the series are generated from a SQL query. I'm able to generate x_labels with an array like this where $day is an array created from a SQL query:

$canvas->x_labels = $day;

but I can't do the same with the series values. I've tried passing an array like:

$canvas->series = array('Number' => $vaules);

where $vaules is an array from a SQL query, and I've also tried to implode the array that I'm passing like this

$array_to_string = implode(",", $value);
$canvas->series = array('Number' => array($array_to_string),);

which doesn't work. The closest to success that I've come is doing this:

$canvas->series = array('Number' => array((int)$number[1],(int)$number[2],(int)$number[3],(int)$number[4],(int)$number[5],(int)$number[6],(int)$number[7]),);

which works, but isn't very dynamic and requires me to always know the dimensions of the graph. Is it possible to build a graph dynamically with this module? I've tried Views Charts, but I was unable to get the aggregation and flexibility I needed. I'm an amature programmer, so my code logic could be way off. Thanks in advance!

Comments

akshaynhegde’s picture

Even am facing this exact problem and its really annoying. So please anybody show a way to do it with sql queries.
Thanks.

akshaynhegde’s picture

Priority: Normal » Critical
akshaynhegde’s picture

anybody...??? I want this answer badly... so please...
Thanks

akshaynhegde’s picture

Status: Active » Fixed

Hi

Finally... I figured it out..:) I thought i should post it here so that it might help somebody else.

@elkabong, the solution to pass the array '$day' is very simple, use array_values() function..!

i.e, for example,

$canvas->x_labels = array_values($day);

similarly for a series,

$canvas->series = array_values($some_array);

The above does work for series, I checked it myself.
I do not know if its a right approach but it worked for me. I hope it was helpfull to sombody..:)

akshaynhegde’s picture

Status: Fixed » Active
WorldFallz’s picture

Priority: Critical » Normal