Deneb Example - Grouping

Deneb/Vega-Lite can be used to adjust the shape of the raw data provided by Power BI. The example visual presented herein consists of (horizontally-concatenated) a line chart and a boxplot. The data is assigned to decades, which are then used as separate lines in the (left) line chart and summarized in the (right) boxplot.

This example illustrates a number of Deneb/Vega-Lite features, including:
0 - General:

  • use of a “transform” block to extend the dataset with an in-visual calculated month, year, and decade
  • use of an “hconcat” block consisting of 2 sections: line, and boxplot

1 - (Grouped) Line Chart:

  • use of a shared encoding block for the (grouped) data and labels (X, Y, colour)
  • use of a “layer” block with 3 overlapping marks - 1x line (month/year within decade) and 2x text (start year, end year)
  • line chart:
    • use of conditional colours, widths, and dashes to alternate the display of the Y-axis gridlines
    • use of a custom Y-axis range
    • use of a Vega-Lite colour scheme (“orangered”) to automatically assign decade colours
    • inclusion of a colour-by-decade legend at bottom-right with custom labels
    • use of “line” mark with smoothing (“monotone”) and variable widths to present the grouped data
    • use of a custom tooltip with Power BI formatting
  • year labels:
    • use of “aggregate” transform to reduce the dataset to only the min and max years
    • use of custom X and Y alignment, baselines, and offsets (left-and-below for start; right-and-above for end)

2 - (Grouped) Boxplot:

  • use of conditional colours, widths, and dashes to alternate the display of the Y-axis gridlines
  • use of a custom Y-axis range
  • use of a Vega-Lite colour scheme (“magma”) to automatically assign decade colours
  • use of a “layer” block with 3 overlapping marks - 1x boxplot (decade) and 2x text (min, max)
  • boxplot:
    • use of “boxplot” mark (all calculations done internally by Vega-Lite, including tooltips; no customization used/required)
  • min and max labels:
    • use of “aggregate” transform to reduce the dataset to only the min and max values within the decade
    • use of custom Y offsets (below for min; above for max)

The intent of this example 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 public data from NOAA’s Barrow, Alaska monitoring station 1973-2021.

Dataset details: Monthly atmospheric carbon dioxide dry air mole fractions from quasi-continuous measurements at Barrow Atmospheric Baseline Observatory (BRW), Alaska, 1973-2021; National Oceanic and Atmospheric Administration (NOAA); Global Monitoring Laboratory (GML); Carbon Cycle Greenhouse Gases (CCGG); Version: 2022-05-03; https://gml.noaa.gov/aftp/data/trace_gases/co2/in-situ/surface/

This example 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 Examples - Grouping.pbix (37.4 KB)

2 Likes

marking as solved