Displaying Charts in Admin Dashboard Widget

I’d like to display a chart with some data in a admin-dashboard widget. But I’m stuck with the loading of my js libs.
Due to the fact, that the widget content is done via renderWidgetContent() the libs included with event.include( assetId = "js-chart" ); are not instantiated.

Is there some example available how to get a chart rendered in the widgets?

I’m also using the chart.js extension, so I tried the quick start example from FORGEBOX: PresideCMS Extension: Chart.js for Preside

I see, that the correct code is written to the output, but a chart isn’t generated (I think due to the loading issue mentioned above).

Has someone a working example for this?

Thanks in Advance,
Michi

Well, at least I found a way to get on .js included via the layout file:

event.include( "/js/admin/specific/#currentHandler#/#currentAction#/", false );

But only one file of this folder is included, and I have no idea why not my second one (but I think this is a different issue).

If I trigger

new Chart( document.getElementById( 'chart72f9611de8b3424997a81ac56cec449c' ), chart72f9611de8b3424997a81ac56cec449c_config );

manually in the js console, the chart is generated, but not automatically on loading the page.

So, I’m one step ahead, but still appreaciate any help.

This should happen automatically. @seb - any ideas?

1 Like