Dynamically building ChartJS objects using passed variables

0
Hi, I have built several ChartJS objects using the https://docs.mendix.com/howto/extendability/visualize-data-using-the-chartsjs-module documentation. Currently these charts' datasource use a microflow where I create variables to statically populate several values (e.g.: Resources, States) which the microflow uses to iterate and filter through (Usage) records. How do I dynamically select some values on the page in a drop-down (e.g. a handful of States) and pass them to the microflow, so that I can assign these microflow variables with these passed values? Any hints are will appreciated, Guislain
asked
1 answers
4

Guislan,

Create a helper entity with either associations or attributes that can be used to constrain your chart results.  I have found that attributes work well for dates (I typically use 2 attributes to enable users to select a month, year, week, etc.) while associations are better suited for values where users may want to select multiple values (states, resources, etc.)

Once the entity is created, you can create an instance each time a chart is needed.  Make a page that displays the newly created object and enables the selection on reference values or entity values.  After the values are selected, you can then create a microflow that is called from a button on the page.  Your entity can be passed to the microflow, and you can use the association values and entity values to constrain your results.

You should consider making your helper entity non persistent or, if its persistent, make sure you have the capability to view and delete the list of these objects so that you don't end up with a large number of unneeded objects in your database.

Hope that helps,

Mike

answered