Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
I’m using a Deneb visual to display the number of tickets across different venues as a bar chart. The number of venues varies depending on the filter selection.
Currently, I’m using "width": { "step": 70 } so that the chart adjusts dynamically with the number of venues. This works fine when there are many venues, since the chart shows a horizontal scrollbar as expected.
However, when only a small number of venues are selected (for example, just 1 or 2), the chart becomes very narrow and leaves a large amount of white space on the right-hand side.
Is there a way to set a minimum width for the visual (or another approach) so that it doesn’t shrink too much when only a few categories are selected?
@Abhijith19 Hi!
"width": "container"
This tells the chart to always fill the width of the Deneb visual.
"width": { "signal": "max(availableWidth, 70 * domain('x').length)" }
domain('x').length → number of categories in your x-axis.
70 * … → your step-based width.
max(availableWidth, …) → enforces a minimum.
In Deneb, availableWidth corresponds to the actual visual size.
BBF
Hello @BeaBF ,
Thanks for the reply.
Option 1: I tried this approach, and it works fine when there are only a few categories on the x-axis. However, when more items are included, the visual tries to fit everything in, which compresses the bars and makes them unreadable. I need to make it dynamic for both conditions.
Option 2: It’s supported only in Vega. I need to use Vega-Lite since I’m using this visual to apply pattern fills.
Really appreciate your help and suggestions.
@Abhijith19 Hi!
You can combine width: "container" with the x.band and x.paddingInner properties to make the bars stay readable even when you have many categories.
Here’s a refined Vega-Lite pattern you can use in Deneb:
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {"name": "dataset"},
"width": "container",
"height": 300,
"mark": {"type": "bar"},
"encoding": {
"x": {
"field": "Venue",
"type": "ordinal",
"axis": {"labelAngle": -40},
"spacing": 0
},
"y": {"field": "Tickets", "type": "quantitative"}
},
"config": {
"bar": {"band": 0.8}, // wider bars (0.7–0.9 works well)
"scale": {
"x": {
"paddingInner": 0.2, // add spacing between bars
"clamp": true // prevents over-squashing of bands
}
},
"view": {"stroke": "transparent"} // removes default border
}
}
BBF
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.