Possible to create a User Dashboard to show graphs of data in widgets?

Hi everyone,

Firstly… i’m a noob to cake… and have had a team of front end devs build out a cakephp site for me. Now I have a new requirement of the site that I have to satisfy and i’m not sure if cake can handle it. I’m working with Cake 3.3.x currently.

I’m wondering if there’s anything out there (plugin wise maybe) that would allow me to have a page on my site that is a dashboard with widgets.
The idea is that a controller would collect data from an api, and then the widgets on the dashboard would graph out that data, or display it in some other way.
The user of the site would be able to move the widgets around… size them bigger, and smaller and basically configure their dashboard to be the way they want it.
They’d be able to pick from a collection of canned widgets to show data they’d want to see.
And their personal configuration of the dashboard would be saved off (maybe in my backend api which is separate from the cakephp instance) so that their personal config can be retrieved before painting the page.

Is this possible in Cake or would it be best to do it in another framework? I’m trying to find plugins for this and the only one i found was gourmet/dashboard but i’m having trouble getting it to install because it wants me to be running 3.0.*-dev version of Cake which i’m not running. Plus it looks like an abandoned project. https://github.com/gourmet/dashboard

Basically i’m doing research to see if I can implement this in Cake or if i should move to another framework.

thanks in advance!

Hii there,

This has very little to do with CakePHP in this case, as the general flow will be identical for all PHP frameworks.
You use the PHP framework (be it CakePHP, Symfony, Laravel etc. etc.) to serve the page itself.
Then, using a piece of Javascript, you make an XHR request to the API (preferably using a CakePHP API as a middleman to cache the results, to prevent a possible DoS or ban, especially if the API is a third-party API like the YouTube API).
After the request completed, you then display it as needed.

You can see an example of it (though, here I don’t use said caching yet) on my website.
Here is the view template that goes along with it:

You could do it using PHP and a library like pChart but honestly, using JavaScript on the client for this is the way to go as it’ll save time loading up the page (especially if there are a few dozen of widgets with each a lot of data), you can make it look better with CSS and you get access to a lot of libraries, like Chart.JS, Chartist.JS, Plotly and EJSCharts (just to name a few).
Additionally, it’ll be a lot more error-resistent since one graph not loading up properly (eg. due to an API that’s offline) doesn’t affect the other graphs (which might come from another source) or the source is down (instead of PHP waiting a long time then throwing an error in your face, you can show a nice gentle error in JavaScript instead without affecting the rest of the page).

Great explanation… thanks … and thanks for the example file! you rock!

1 Like