Deneb Template - Space-Saving Bar Chart

The horizontal space available to the standard bar chart visual in Power BI is divided into three areas (the category [the y axis], the value [the bar], and the data label); as well, long categories are often shortened (fewer characters and an ellipsis). With Deneb, we can avoid this overflow impact and maximize the horizontal space available for the bar by controlling the position of the category, and I enclose a Deneb/Vega-Lite template for such a space-saving bar chart.

This template illustrates a number of Deneb/Vega-Lite features, including:

  • a shared Y “encoding” block outside the layered 3 marks (bar, category, data label)
  • a “sort” block in the y axis encoding to display the bars in descending value order
  • a Deneb formatting of data labels using Power BI formatting strings
  • a Deneb formatting of x-axis labels using Power BI formatting strings
  • optional properties (colour, fontSize, fontStyle, and fontWeight) to customize of the display the text marks as desired

The intent of this template is not to provide a finished visual, but rather to serve as a starting point for further custom visual development.

Also included is the sample PBIX using the Enterprise DNA Practice Dataset as a demo.

NOTE: This template is provided as-is for information purposes only, and its use is solely at the discretion of the end user; no responsibility is assumed by the author.

Greg

deneb.space_saving_bar_chart.0.2.json (4.5 KB)
Deneb Templates - Space-Saving Bar Chart.pbix (1.7 MB)

4 Likes

marking as solved

1 Like

Hi @Greg, thanks for sharing this example. I want to use this idea to understand how to control the spacing between bars.
Over your example I noticed that increasing a bit the size that works, but if I want the bars with more height and keep white space between category and bars, I cannot find a solution to that.
I read over Vega-Lite documentation that is with BinSpacing but it seems I’m doing something wrong because there is no impact when I apply to the mark code.

Hi @scancela.90

It may be unlikely that your issue/question elicits any responses when posting to a solved thread. In the future, please create a new thread for each new issue/question (and link a previously-solved post, if it helps). Regardless …

Yes, there is. There are probably multiple ways of doing this in Vega-Lite. Here’s one: add a height block to the top level of the specification and set the step value as desired.

---
  "height": {"step": 50}
---

Here’s an example using a step of 50.

Hope this helps.
Greg
eDNA Forum - Deneb Bar Spacing.pbix (1.7 MB)

1 Like