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

Gantt Chart

Gantt chart for Power BI built with Deneb: tasks on the Y axis, rounded bars with their duration inside, and full cross-filter.

Vega-Lite gantt ✓ Cross-filter✓ Tooltip✓ Context menu✓ Selection

Live preview

Rendered with sample data · Vega/Vega-Lite

🖱️ Live cross-filter — click a mark and the others filter or dim right here (Deneb's runtime reused, MIT). Just like in Power BI.

Gantt Chart 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__ Task text
  2. __1__ End_Day number measure
  3. __2__ Start_Day number measure
  4. __3__ Task_Order number measure
  5. __4__ Duration number measure

Drag your fields into Values in this order.

🎯 Technique

Engine
Vega-Lite 5.20.1
Marks
bar, text

🛠️ How it is built

Adapted from a Vega-Lite example and customised for Deneb. The label inside each bar shows the task's duration; tasks are sorted on the Y axis and the bars have rounded corners. Cross-filter works fully, so it fits any process where the timing and order of activities matter.

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: Task , End_Day , Start_Day , Task_Order , Duration .
  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": "Plantilla de diagrama de Gantt, adaptada de Vega-Lite y personalizada para Deneb en Power BI. Incluye etiquetas dentro de las barras con la duración de cada tarea y un título descriptivo para facilitar la lectura. Por CSalcedoDataBI · https://csalcedodatabi.com/deneb/gantt-chart",
  "usermeta": {
    "information": {
      "uuid": "a1aa3117-60f0-4be2-9c86-992c757746f6",
      "generated": "2024-08-16T03:43:41.186Z",
      "previewImageBase64PNG": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=",
      "name": "Gantt Chart",
      "description": "This Gantt chart template, adapted from Vega-Lite and customized for Deneb in Power BI, provides a clear and functional visualization. Autor: Cristobal Salcedo Beltrán.",
      "author": "Cristobal Salcedo Beltrán"
    },
    "deneb": {
      "build": "1.7.1.0",
      "metaVersion": 1,
      "provider": "vegaLite",
      "providerVersion": "5.20.1"
    },
    "interactivity": {
      "tooltip": true,
      "contextMenu": true,
      "selection": true,
      "selectionMode": "simple",
      "highlight": false,
      "dataPointLimit": 50
    },
    "config": "{\r\n  \"view\": {\r\n    \"stroke\": \"transparent\"\r\n  },\r\n  \"background\": \"transparent\",\r\n  \"axisX\": {\r\n    \"orient\": \"bottom\",\r\n    \"offset\": 5,\r\n    \"grid\": true,\r\n    \"tickRound\": true,\r\n    \"labelFontSize\": 14,\r\n    \"tickCount\": 2\r\n  },\r\n  \"axisY\": {\r\n    \"domain\": false,\r\n    \"tickWidth\": 46,\r\n    \"tickSize\": 300,\r\n    \"tickColor\": {\r\n      \"expr\": \"split(datum.value,'|')[0]=='on'?'#08534b': '#eee'\"\r\n    },\r\n    \"labelColor\": {\r\n      \"expr\": \"split(datum.value,'|')[0]=='on'?'white': 'black'\"\r\n    },\r\n    \"offset\": 15,\r\n    \"grid\": false,\r\n    \"tickRound\": true,\r\n    \"labelFontSize\": 18,\r\n    \"labelAlign\": \"left\",\r\n    \"labelLimit\": 370,\r\n    \"labelPadding\": -4,\r\n    \"titleAlign\": \"left\",\r\n    \"titleAnchor\": \"start\",\r\n    \"titleAngle\": 0,\r\n    \"titleFontSize\": 20,\r\n    \"titlePadding\": -12,\r\n    \"titleY\": -5\r\n  }\r\n}",
    "dataset": [
      {
        "key": "__0__",
        "name": "Task",
        "description": "",
        "kind": "column",
        "type": "text"
      },
      {
        "key": "__1__",
        "name": "End_Day",
        "description": "",
        "kind": "measure",
        "type": "numeric"
      },
      {
        "key": "__2__",
        "name": "Start_Day",
        "description": "",
        "kind": "measure",
        "type": "numeric"
      },
      {
        "key": "__3__",
        "name": "Task_Order",
        "description": "",
        "kind": "measure",
        "type": "numeric"
      },
      {
        "key": "__4__",
        "name": "Duration",
        "description": "",
        "kind": "measure",
        "type": "numeric"
      }
    ]
  },
  "data": {
    "name": "dataset"
  },
  "transform": [
    {
      "calculate": "datum.__selected__+'|'+ datum['__0__']",
      "as": "selectedTask"
    }
  ],
  "encoding": {
    "y": {
      "field": "selectedTask",
      "type": "ordinal",
      "axis": {
        "title": "__0__",
        "labelExpr": "split(datum.value,'|')[1]"
      },
      "sort": {
        "field": "__3__"
      }
    },
    "x": {
      "field": "__2__",
      "type": "quantitative"
    },
    "x2": {
      "field": "__1__",
      "type": "quantitative",
      "title": ""
    }
  },
  "layer": [
    {
      "name": "Mark_barLegend",
      "mark": {
        "type": "bar",
        "color": "#08534b",
        "height": 20,
        "width": 10
      },
      "encoding": {
        "x": {
          "value": {
            "expr": "width/2.5"
          }
        },
        "x2": {
          "value": {
            "expr": "width/2.3"
          }
        },
        "y": {
          "value": -25
        }
      }
    },
    {
      "name": "Mark_textLegend",
      "mark": {
        "type": "text",
        "align": "left",
        "color": "#020202",
        "fontSize": 25
      },
      "encoding": {
        "text": {
          "value": "__4__"
        },
        "x": {
          "value": {
            "expr": "width/2.2"
          }
        },
        "y": {
          "value": -25
        }
      }
    },
    {
      "name": "Mark_barChart",
      "mark": {
        "type": "bar",
        "color": "#08534b",
        "cornerRadiusTopRight": 5,
        "cornerRadiusBottomRight": 5
      },
      "encoding": {
        "opacity": {
          "condition": {
            "test": {
              "field": "__selected__",
              "equal": "off"
            },
            "value": 0.3
          },
          "value": 1
        }
      }
    },
    {
      "name": "Mark_textChart",
      "mark": {
        "type": "text",
        "fontSize": 15,
        "align": "left",
        "color": "#fff",
        "dx": 8
      },
      "encoding": {
        "text": {
          "value": {
            "expr": "datum['__4__'] +' days'"
          }
        }
      }
    }
  ],
  "title": {
    "text": "Hiring Process Gantt Chart - 49 Days Overview",
    "fontSize": 25,
    "anchor": "middle",
    "frame": "bounds",
    "offset": 15
  }
}
Get in touch!