Sprinkle that Integrates Charts on Admin Pages

FYI, this is not necessary with UF4, as it’s included in php bakery build-assets.

@frankfont This is the dashboard url. http://localhost/userfrosting/public/dashboard#&sort[table-activities][occurred_at]=desc&page[table-activities]=1&size[table-activities]=10

See also my post on 3 dec on the errors in console, it seems that ‘userfrosting/public/’ is missing there.

I’ve run the command several times, no errors, but not with the desired result.

Looks like you have a webserver configuration issue. The baseurl for the working page you shared is " http://localhost/userfrosting/" but the baseurl getting used for the sprinkle routes is simply http://localhost.

If you are running Apache webserver, I think there is a value you can set in a config to declare the docroot as a path that includes a subdirectory; but I don’t recall what that would be.

Easier solution is to make Userfrosting the default website at the root of your server.

It seems indeed a webserver configuration issue, but it’s normal to use subdirectories for testing different environments. (e.g. Laravel where I’m also experimenting with). BTW there is no problem with the 3 other UF-Sprinkles. I have to dig into the UF-Sprinkles technique further and then I will look at your Sprinkle again. I will also try to enlarge my simple custom test-Sprinkle with Chart.js, and try to generate charts as your Sprinkle does. Hope I will succeed.

@Malou — would you know if there is anything a sprinkle author should do as a best practice so the base url comes out the same as what is used in the core routes? I’m guessing from @franky 's feedback that the core routes are dealing with the subfolder but the sprinkle is not.

Or is it some kind of additional “bake” step that might fix it?

@Franky thanks for sharing your install details — I have learned something and there is now a fix for the issue you reported.

Turns out UserFrosting has a nice baseurl value (site.uri.public) available to the javascript assets, and I was not using it. The updated sprinkle is now in the repo; should work for you too.

1 Like

@frankfont thanks for digging in. It’s now working :sunglasses: I’ve guessed myself that there would be some problem in the Sprinkle itself, but didn’t had the time yet to dig in to it. Tip: your Sprinkle loads in the vendor-assets Font-Awesome and Moment, but they are already loaded in the core Sprinkle. In fact you won’t need them to load again, the Sprinkle system works fine on this point. Only when you need a specific version, then it’s advisable.