A standard Power BI bar chart has screen real estate taken-up by the Y-axis and data values. One can also use the horizontal bar chart custom visual from Microsoft to recover the space taken-up by the y-axis, but the data labels still take-up space. Deneb/Vega-Lite offers the possibility of using internal labels and values to dedicate all or the visuals’ width to the bars. One of the interactive features built-in to the Vega-Lite language is the ability to alter a visuals’ composition/appearance during run-time by using parameters bound to screen widgets. Vega-Lite also has the ability to filter datasets in-visual, during run-time, again by using parameters bound to screen widgets. A bar chart can be used to effectively illustrate these features, and I enclose a Deneb/Vega-Lite template for such a bar chart.
This template illustrates a number of Deneb/Vega-Lite features, including:
- a parameters block to create and bind top N and corner radius screen widgets
- a transformation block to filter the dataset to the top N selection of the screen widget
- a hidden Y-axis using un-related field sorting (sorted descending by the “Total Sales”)
- a quantitative X-axis with label formatting using Deneb’s ability to access Power BI formatting strings and approximate tick count
- 3 overlapping layers:
- a 100% width bar with corner radius bound to a screen widget
- a “Country” label left-aligned inside the left end of the bar
- a “Total Sales” label right-aligned inside the right end of the bar
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.
EDIT: resolved Deneb v1.1 template generation issue and uploaded new template version
Greg
deneb.top_n_bar_chart_with_internal_labels_and_values.0.3.json (3.6 KB)
Deneb Templates - Top N Bar Chart with Internal Labels and Values.pbix (1.7 MB)