Using RGraph within CakePHP...simple chart is not showing up

Share RGraph:   To help my Google visibility (it can't get much worse!), if you like and use RGraph I'd appreciate it if you could link to me

« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by Neil on 17th April 2014
Are there special considerations in using RGraph within a CakePHP application?
The necessary is files have been loaded in the webroot/js folder, and $this->Html->script('jsfile') used, along with fetch(script) as stadard helpers.
The RGraph used was the very simple RGraph.Line example with static data. It worked fine in a standalone html page, but within the CakePHP framework the canvas was present in the output page, but no drawing was visible.
The only difference that I could find between the source code of the plain html page and the page that was output by CakePHP was "../js/javascriptFileName" in the working page, but the double dot did not appear in the generated code. However, jQuery commands worked under the same conditions, so not sure if that's relevant.
It appears that the "new Graph()" function is not being invoked (since there are only static variables I'm using straight HTML rather than <?php echo etc.
Does anyone have any wisdom to offer?
Neil
Posted by Richard on 17th April 2014
Hi there,

Sorry - never used Cake. You could try using absolute paths for the script files:

<script src="/js/RGraph.common.core.js"></script>
<script src="/js/RGraph.bar.js"></script>

Also check your browsers JavaScript console for any error message - if the file isn't being included you'll probably see an undefined error.





Richard
www.rgraph.net
If RGraph has helped you - please share the website - thanks!

RGraph Priority Support: www.rgraph.net/support#priority-support
Posted by Neil on 18th April 2014
Thanks, Richard, for such a speedy reply.
Following your suggestions, I found that while the RGraph files are successfully located, they are not loading completely (on inspection, they are cut off about one third of the way through). This is not a problem with the files themselves - they work well in a standalone environment - but with whatever else might be going on that interrupts the complete loading of Javascript files. Is there generic information out there on handing this, or is it likely to be a quirk of the (Cake) framework?
It's an imposition, I know. It's frustrating to be so close to using RGraph...and not yet.
All the best,
Neil
Posted by Richard on 18th April 2014
Hi there,

If you're using Cake to load the files try without - with just a regular script tag like these:

<script src="/js/RGraph.common.core.js"></script>
<script src="/js/RGraph.bar.js"></script>

And try a page without Cake (a standalone HTML page) and see if the libraries load correctly. Use one of the basic examples:

www.rgraph.net/demos/basic-bar.html




Richard
www.rgraph.net
If RGraph has helped you - please share the website - thanks!

RGraph Priority Support: www.rgraph.net/support#priority-support
Posted by Neil on 18th April 2014
Thanks, Richard. Having tried these and other variations, the problem is definitely with CakePHP - the JavaScript libraries load properly in a standalone environment.

I will look for solutions in the Cake community, and not trouble you any more.

Thanks for your help - I have learned a lot through your suggestions.

All the best.

Add a reply




« Back to message list