Hi Céryl, This was very useful for me as I'm trying to use flot as well.
I did something similar by first trying to build up an array of tuples and then used the $javascript->object() function which produces a JSON array which is perfect input for flot e.g. foreach($data as $key => $val){ $flot_data[] = array( $key, $val ); //append onto flot_data array } $output = $javascript->object($flot_data); Cheers, Ian On May 18, 9:34 pm, Céryl <c.a.h.wilt...@student.tue.nl> wrote: > Worked almost a charm... Still, I ended up writing a this codeblock to > manually make-up the output the way I want it: > > $i=0; > $output = "["; > foreach($data as $key=>$val){ > if ($i != 0) {$output .= ", ";} > > $output .= "[".$key.", ".$val."]"; > $i++;} > > $output .= "]"; > echo $output; > > It makes thearraylook like the string [[x,y],[x,y]...[x,y]] whith > which I used Codeblock to generate the javaCode. Thanks all! > > On 18 mei, 19:08, brian <bally.z...@gmail.com> wrote: > > > You couldusethe JavascriptHelper to create thearray, or any other > > block of JS code. > > > On Mon, May 18, 2009 at 12:10 PM, Céryl <c.a.h.wilt...@student.tue.nl> > > wrote: > > > > Hej all! > > > > I've been trying to find a solution for this, and maybe I'm > > > approaching it wrong. This is the case: > > > > For my site I need make graphs out of data in a table. I have picked > > > JQuery FLOT for making the graphs. However, FLOT needs data in a > > > jQueryarraybuild like: > > > > [[xaxis, yaxis] > > > [xaxis, yaxis] > > > [xaxis, yaxis]]; > > > > and then calls the plot graph function in FLOT to build it. These > > > functions (With thearraycurrently hardcoded) are in my project in a > > > seperate .js file I load in my view. > > > > However, When I get into my controller and get the relevant data, and > > > pass it to the view using Cake's Set, how can I get that (PHP)array > > > converted and passed to thejavascript(.js file) that builds the > > > graph? > > > > Has anybody any expierience or idea's with this? And if there are > > > graphing libraries that allow for on-the-fly graphs from a database, > > > that work better with Cake, please tell me! Now it's not to late to > > > switch! > > > > Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---