Mendix 9.24.26 chart widgets, bar, Line and pie charts to set default value 0 setting. if data is not available for specific month& year

0
For all graphs line and Bar graph , the X‑axis must include all months. If data for any month is missing, it should be displayed as zero.we have a morethan 20 grpahs where we used the Line, Bar, Pie charts. Please tell me is there any settings to set '0' defualts if data is not available specific month& Year.Let say example: Unique User count per each month.xaxis = June2025, yaxis:count=2 ,xaxis = July2025, yaxis:count=1xaxis = Sep2025, yaxis:count=3,xaxis = Nov2025, yaxis:count=1In the above, the data for Aug2025, Oct2025 is not available so Please tell me how to set default value zero '0' in Mendix chart graphs?and is there any settings in the charts of Mendix to set dafualt value is zero, if data itself not avaialable for specific month in the entity?Thank you.
asked
2 answers
0

There is no built-in setting in Mendix charts to automatically show missing months with value 0. The chart only displays the data points that exist in its datasource.


Because of that, the usual solution is to prepare the dataset before sending it to the chart. If a month has no data, you must still include that month in the datasource with value 0.


A common approach is to use a helper entity or a datasource microflow. In that logic, you generate all months for the selected year and then match the existing records. If a month does not have data, you create a record with count = 0.


So the dataset returned to the chart should already contain all months. For example:

Jun 2025 = 2

Jul 2025 = 1

Aug 2025 = 0

Sep 2025 = 3

Oct 2025 = 0

Nov 2025 = 1


Once the chart receives a complete list including the months with zero values, the X-axis will show all months correctly.


If this resolves your issue, please mark the answer as accepted so it can help others in the community as well.

answered
0

Hi,


In Mendix Charts (Line / Bar / Pie widgets) there is no built-in setting to automatically show missing categories with value 0. The chart only renders data that exists in the dataset returned to the widget. So if August or October does not exist in the returned list, the chart simply skips those months.

Because of that, the correct solution is not a chart setting, but preparing the dataset before sending it to the chart so that all months exist with value 0 when no data is found.

Below is the standard approach most Mendix developers use.

1. Create a helper entity for chart data

Example entity:

ChartMonthlyData

Attributes:

  • Month (String or Enum)
  • Year (Integer)
  • Count (Integer)

This entity will be used to build the dataset sent to the chart.

2. Create a Microflow that prepares the full dataset

Example microflow:

MF_GetMonthlyChartData

Steps:

Step 1 – Create a list containing all 12 months

Loop from 1 → 12 and create objects like:

Month

Count

Jan

0

Feb

0

Mar

0

...

...

Dec

0

So initially all months already exist with Count = 0.

Step 2 – Retrieve actual data

Retrieve your real data from database.

Example:

SELECT Month, COUNT(User)
GROUP BY Month

Or retrieve entity records filtered by the selected Year.

Step 3 – Update the month values

Loop through the real data and update the matching month object.

Example logic:

For each RetrievedRecord
   Find MonthObject in MonthlyList
   ChangeObject:
      Count = RetrievedRecord.Count

Now months without data will remain 0, and months with data will have their correct count.

4. Return this list to the Chart

Set the chart Data source = Microflow

Use the list returned by MF_GetMonthlyChartData.

Configure:

Category (X-axis) → Month

Value (Y-axis) → Count

5. Result

Even if the database contains:

June  = 2
July  = 1
Sep   = 3
Nov   = 1

The dataset sent to the chart will be:

Jan 0
Feb 0
Mar 0
Apr 0
May 0
Jun 2
Jul 1
Aug 0
Sep 3
Oct 0
Nov 1
Dec 0

So the chart always shows all months, and missing months automatically display 0.

Important

This behavior is expected because Mendix Charts simply visualize the dataset they receive. They do not generate missing categories automatically.

So the correct Mendix approach is to prepare the data in a microflow before sending it to the chart.

If you want, I can also show you a clean microflow structure used in production Mendix apps for monthly charts (very optimized for performance).


answered