Custom column chart

0
I need to build a custom column chart, which shos monthly data of forms per form category and also form status. I also need to be able to apply filters , which will modify the chart and shows data either on category or status or both.
asked
3 answers
1

Hi,


You can implement this requirement using the Charts module (AnyChart) with a microflow data source that prepares aggregated data based on filters. This is the standard pattern used in Mendix for dynamic dashboards.

1. Prepare a chart dataset entity

Create a Non-Persistable Entity (for example ChartDataset) with attributes like:

  • Month (String or DateTime formatted to Month)
  • Category (String / Enum)
  • Status (Enum)
  • Count (Integer)

This entity will hold the aggregated result used by the chart.

2. Create a microflow to build chart data

Create a microflow (for example MF_GetChartData) and set it as the data source of the chart.

In this microflow:

  1. Retrieve the Form records with filters applied (Category / Status).
  2. Apply filtering using the values selected by the user (usually stored in a helper object like DashboardFilter).
  3. Aggregate the results per Month + Category or Month + Status.
  4. For each group, create a ChartDataset object and set:
    • Month
    • Category or Status
    • Count

If the dataset is large, the recommended approach is to use OQL with GROUP BY to calculate the counts efficiently.

Example idea:

SELECT
    DATEPART(MONTH, CreatedDate) AS Month,
    Category,
    Status,
    COUNT(*) AS Count
FROM Form
GROUP BY Month, Category, Status

Then convert the result to ChartDataset objects.

3. Configure the Column Chart

Add a Column Chart widget and configure:

Data source → Microflow

Microflow → MF_GetChartData

Chart configuration:

  • Category axisMonth
  • SeriesCategory or Status
  • ValueCount

4. Implement filters

Create a Filter helper entity like DashboardFilter with attributes:

  • Category
  • Status

Add dropdowns or combo boxes on the page bound to this object.

When the filter value changes:

  • Trigger a nanoflow/microflow
  • Refresh the filter object
  • This causes the chart to re-execute the data source microflow and update automatically.

The flow becomes:

User selects filter → Filter object updated → Chart data microflow runs → Aggregated dataset returned → Column chart refreshes.

This approach is the recommended Mendix pattern for building dynamic filtered charts without creating a custom widget.


answered
2

Hi Anand Prakash


Yeah sure you can build it as pluggable widget.  check out this link Widgets or else another you can check the marketplace module Advance cloumn


I hope it helps!

answered
1

Hi,


If you need that level of flexibility (grouping by category, status, or both, and applying filters), it is usually easier to build the chart using a more flexible chart widget such as AnyChart or Plotly from the Marketplace rather than relying only on the default chart widgets.


A common approach is to handle the filtering and aggregation in a microflow. The microflow retrieves the form data, applies the selected filters, and aggregates the results per month. Depending on the filter selection, you can group the data by category, status, or a combination of both.


The aggregated data can then be stored in a helper entity (for example something like Month, Category, Status, Count). This dataset can be returned to the chart widget, which will simply visualize the prepared data.


When the user changes a filter, you can trigger the microflow again to retrieve and aggregate the data with the new filter values, and then refresh the chart. This allows the chart to dynamically update based on the selected filters.


If the dataset becomes large, another option is to perform the aggregation using OQL or a database view, which can sometimes be more efficient than processing everything inside a microflow.


So in general, the best pattern is to let the microflow handle filtering and aggregation, and let the chart widget focus only on displaying the data.


If this approach works for you, please consider marking it as accepted so it can help others as well. 🙂


answered