How to Set Fixed Bar Width in Default Column Chart for Varying Number of Bars?
0
Hi everyone, I'm currently using the default Column Chart widget in Mendix and facing an issue related to bar width consistency based on the number of data points (years). π My Use Case: I generate a year-wise bar chart dynamically using a microflow. The X-axis represents years (e.g., 2022, 2023, 2024, etc.). The Y-axis shows calculated values based on my custom logic. The data set is dynamic β meaning the number of years (bars) shown can vary. Sometimes only one or two years, other times 10+ years. π¨ The Problem: When there are only 1 or 2 bars, the bars expand to fill the entire chart width, which makes them look overly wide and disproportionate. This looks visually unappealing. However, when there are multiple years (e.g., 5 or more), the bars appear properly spaced and sized. π― My Goal: I want to achieve consistent bar width, such that: If only one or two years are shown, the bars should remain narrow and centered, not stretched across the full chart width. If more years are shown, the spacing and size should stay consistent. I am using only the default Mendix Column Chart widget, not AnyChart or custom JavaScript widgets. π What Iβve Tried: Tweaked bargap, bargroupgap, and margins in the Custom Layout JSON of the chart. Tried limiting chart width at the page level to force the bars to shrink. Considered setting dynamic conditions inside JSON (e.g., based on count of years), but the default widget doesnβt support expressions in the layout. β My Question: Is there a way β using the default Column Chart widget in Mendix β to ensure that bar widths stay fixed or consistent, regardless of the number of years shown on the X-axis? If not directly possible, are there any reliable workarounds or best practices to achieve this effect?