Esta página también está en español. Leer en español →

Stacked Bar Chart with Rounded Corners

Stacked bars with rounded corners for Power BI with Deneb, based on an official Vega-Lite example. Cross-filter is limited when aggregate is used.

Vega-Lite stacked-bar ✓ Tooltip✓ Context menu

Live preview

Rendered with sample data · Vega/Vega-Lite
Stacked Bar Chart with Rounded Corners Loading preview…

Preview rendered with the runtime of Deneb · MIT © Daniel Marsh-Patrick

The sample data and the chart's own titles stay as they ship in the spec.

🔽 Download (.pbix, Spanish labels) 🔽 Download spec .json

🧩 Fields it expects

  1. __0__ Date dateTime
  2. __1__ Category text

Drag your fields into Values in this order.

🎯 Technique

Engine
Vega-Lite 5.16.3
Marks
bar, text
Power BI
  • pbiColorNominal: report theme colour scheme for categories
  • pbiFormat: applies Power BI's number or date format to a value

How to use it in Power BI

  1. Add the Deneb visual to your report and open its editor.
  2. Drag your fields into Values in this order: Date , Category .
  3. Paste the spec (the «Copy spec» button above) into Deneb's JSON editor.
  4. Map your columns and adjust it to taste. The native interactivity is already set up.
See the full spec: Vega-Lite
spec.vega-lite.json
{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "description": "Gráfico de barras apiladas con esquinas redondeadas. Basado en un ejemplo oficial de Vega-Lite y adaptado para Deneb en Power BI; ten en cuenta que la interactividad de cross-filter es limitada cuando se usa ‘aggregate’. Por CSalcedoDataBI · https://csalcedodatabi.com/deneb/stacked-bar-chart-with-rounded-corners",
  "usermeta": {
    "deneb": {
      "build": "1.6.2.1",
      "metaVersion": 1,
      "provider": "vegaLite",
      "providerVersion": "5.16.3"
    },
    "interactivity": {
      "tooltip": true,
      "contextMenu": true,
      "selection": false,
      "highlight": false,
      "dataPointLimit": 50
    },
    "information": {
      "name": "Stacked Bar Chart With Rounded Corners",
      "description": "Based on an official Vega-Lite example and adapted for use in Deneb within Power BI, it should be noted that cross-filtering interactivity is limited when using 'aggregate'. Autor: Cristobal Salcedo Beltrán.",
      "author": "Cristobal Salcedo Beltrán",
      "uuid": "43117c42-9880-4a5e-9526-27d9a4954b1d",
      "generated": "2024-07-16T22:46:34.108Z"
    },
    "dataset": [
      {
        "key": "__0__",
        "name": "Date",
        "description": "",
        "type": "dateTime",
        "kind": "column"
      },
      {
        "key": "__1__",
        "name": "Category",
        "description": "",
        "type": "text",
        "kind": "column"
      }
    ]
  },
  "config": {
    "axisY": {
      "labelFontSize": 18,
      "tickCount": 6,
      "gridDash": [
        4,
        8
      ]
    },
    "axisX": {
      "labelFontSize": 18,
      "offset": 1,
      "labelExpr": "[pbiFormat(datum.value,'MMM')]"
    },
    "legend": {
      "orient": "top",
      "labelFontSize": 18
    }
  },
  "data": {
    "name": "dataset"
  },
  "title": {
    "text": "Weather Distribution by Month",
    "fontSize": 30
  },
  "name": "Mark_BarChart",
  "mark": {
    "type": "bar",
    "cornerRadiusTopLeft": 15,
    "cornerRadiusTopRight": 15,
    "tooltip": true
  },
  "encoding": {
    "x": {
      "timeUnit": "month",
      "field": "__0__",
      "type": "ordinal",
      "title": null
    },
    "y": {
      "aggregate": "count",
      "type": "quantitative",
      "title": null
    },
    "color": {
      "field": "__1__",
      "type": "nominal",
      "scale": {
        "domain": [
          "sun",
          "fog",
          "drizzle",
          "rain",
          "snow"
        ],
        "scheme": "pbiColorNominal"
      },
      "title": null
    }
  }
}
Get in touch!