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

Ranking Over Time (Bump Chart)

Bump chart with Deneb: each line is a category and its height is its rank in each period. The ranking is computed inside the spec.

💡 When to use it

When ORDER matters more than magnitude: who overtakes whom, period by period. Best with few series (up to ~8) across several periods; if the magnitude is the point, use a plain line chart.

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

Live preview

Rendered with sample data · Vega/Vega-Lite

The hover highlight (one series stands out and the rest dim) runs LIVE here on the web: it is a Vega-Lite point select on pointerover. Dimming through __selected__ is the other half — only Power BI turns it on when another visual filters this one, although the gallery simulates the click in the view itself.

Ranking Over Time (Bump 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 (PBIP, Spanish labels) 🔽 Download spec .json

🧩 Fields it expects

  1. __0__ SubCategoryName text
  2. __1__ YearMonth text
  3. __2__ Total Sales number measure

Drag your fields into Values in this order.

🎯 Technique

Engine
Vega-Lite 5.16.3
Marks
line, point, text

🛠️ How it is built

The rank does not come from the model: a window rank per period computes it inside the spec, so changing the ordering measure needs no change to the semantic model. Hovering a line dims the rest so you can follow its path.

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: SubCategoryName , YearMonth , Total Sales .
  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": "Cada línea es una categoría y su altura es el puesto que ocupa en cada periodo: 1º arriba. El puesto NO viene del modelo — se calcula dentro del spec con un window rank por periodo, así que cambiar la medida que ordena no exige tocar el modelo semántico. Por CSalcedoDataBI · https://csalcedodatabi.com/deneb/ranking-bump-chart",
  "usermeta": {
    "deneb": {
      "build": "1.6.2.1",
      "metaVersion": 1,
      "provider": "vegaLite",
      "providerVersion": "5.16.3"
    },
    "interactivity": {
      "tooltip": true,
      "contextMenu": true,
      "selection": true,
      "highlight": true,
      "dataPointLimit": 200
    },
    "information": {
      "name": "Ranking en el tiempo (bump chart)",
      "description": "Bump chart de ranking: el puesto de cada categoría se recalcula dentro del propio spec con un window rank por periodo. Autor: Cristobal Salcedo Beltrán.",
      "author": "Cristobal Salcedo Beltrán"
    },
    "dataset": [
      {
        "key": "__0__",
        "name": "SubCategoryName",
        "description": "Serie que compite en el ranking (una línea por valor)",
        "type": "text",
        "kind": "column"
      },
      {
        "key": "__1__",
        "name": "YearMonth",
        "description": "Eje temporal del ranking, ya al grano que quieres ver",
        "type": "text",
        "kind": "column"
      },
      {
        "key": "__2__",
        "name": "Total Sales",
        "description": "Medida que ordena el ranking dentro de cada periodo",
        "type": "numeric",
        "kind": "measure"
      }
    ]
  },
  "config": {
    "background": "transparent",
    "font": "Segoe UI",
    "view": {
      "stroke": "transparent"
    },
    "axis": {
      "grid": false,
      "domain": false,
      "ticks": false,
      "labelColor": "#605E5C",
      "labelFontSize": 12.5,
      "titleColor": "#252423",
      "titleFontWeight": "normal"
    },
    "text": {
      "font": "Segoe UI"
    }
  },
  "title": {
    "text": "Ranking de subcategorías por ventas · 2023–2024",
    "subtitle": [
      "Top 6 por ventas totales · 1º arriba",
      "Contoso Retail · pasa el cursor por una línea para seguirla"
    ],
    "anchor": "middle",
    "font": "Segoe UI",
    "fontSize": 21,
    "fontWeight": 600,
    "color": "#1B1A19",
    "subtitleFont": "Segoe UI",
    "subtitleFontSize": 12,
    "subtitleFontWeight": "normal",
    "subtitleColor": "#8A8886",
    "subtitleLineHeight": 17,
    "subtitlePadding": 10,
    "offset": 24
  },
  "height": 340,
  "padding": {
    "left": 4,
    "top": 4,
    "bottom": 4,
    "right": 12
  },
  "data": {
    "name": "dataset"
  },
  "transform": [
    {
      "joinaggregate": [
        {
          "op": "sum",
          "field": "__2__",
          "as": "totalSerie"
        }
      ],
      "groupby": [
        "__0__"
      ]
    },
    {
      "window": [
        {
          "op": "dense_rank",
          "as": "puestoSerie"
        }
      ],
      "sort": [
        {
          "field": "totalSerie",
          "order": "descending"
        }
      ]
    },
    {
      "filter": "datum.puestoSerie <= 6"
    },
    {
      "window": [
        {
          "op": "rank",
          "as": "ranking"
        }
      ],
      "groupby": [
        "__1__"
      ],
      "sort": [
        {
          "field": "__2__",
          "order": "descending"
        }
      ]
    },
    {
      "window": [
        {
          "op": "row_number",
          "as": "pasoFinal"
        }
      ],
      "groupby": [
        "__0__"
      ],
      "sort": [
        {
          "field": "__1__",
          "order": "descending"
        }
      ]
    }
  ],
  "encoding": {
    "x": {
      "field": "__1__",
      "type": "temporal",
      "title": null,
      "scale": {
        "type": "utc",
        "padding": 18
      },
      "axis": {
        "format": "%b %y",
        "tickCount": {
          "interval": "month",
          "step": 3
        },
        "labelAngle": 0,
        "labelPadding": 14,
        "grid": true,
        "gridColor": "#F0EEEC",
        "gridWidth": 1
      }
    },
    "y": {
      "field": "ranking",
      "type": "quantitative",
      "title": null,
      "scale": {
        "reverse": true,
        "nice": false,
        "zero": false,
        "padding": 26
      },
      "axis": {
        "tickMinStep": 1,
        "labelExpr": "datum.value + 'º'",
        "labelPadding": 14,
        "labelFontWeight": 600,
        "labelColor": "#3B3A39"
      }
    },
    "color": {
      "field": "__0__",
      "type": "nominal",
      "legend": null,
      "scale": {
        "range": [
          "#2E5E7E",
          "#C9724A",
          "#4C8577",
          "#A8456B",
          "#7E6BB0",
          "#B08A1E"
        ]
      }
    },
    "opacity": {
      "condition": [
        {
          "test": "datum.__selected__ === 'off'",
          "value": 0.12
        },
        {
          "param": "serieHover",
          "value": 1
        }
      ],
      "value": 0.16
    }
  },
  "layer": [
    {
      "description": "Cinta invisible y ancha: es la que recibe el cursor (una línea de 3 px no se atrapa). Anula la opacidad heredada para no pintarse nunca.",
      "mark": {
        "type": "line",
        "interpolate": "monotone",
        "strokeWidth": 22
      },
      "params": [
        {
          "name": "serieHover",
          "select": {
            "type": "point",
            "fields": [
              "__0__"
            ],
            "on": "pointerover",
            "clear": "pointerout"
          }
        }
      ],
      "encoding": {
        "opacity": {
          "value": 0
        }
      }
    },
    {
      "description": "La línea visible.",
      "mark": {
        "type": "line",
        "interpolate": "monotone",
        "strokeCap": "round",
        "strokeJoin": "round"
      },
      "encoding": {
        "strokeWidth": {
          "condition": {
            "param": "serieHover",
            "empty": false,
            "value": 4.5
          },
          "value": 3
        }
      }
    },
    {
      "description": "Los nodos: un punto por periodo, con halo blanco para que el cruce se lea.",
      "mark": {
        "type": "point",
        "filled": true,
        "stroke": "#FFFFFF",
        "strokeWidth": 2.5
      },
      "encoding": {
        "size": {
          "condition": {
            "param": "serieHover",
            "empty": false,
            "value": 170
          },
          "value": 110
        },
        "tooltip": [
          {
            "field": "__0__",
            "type": "nominal",
            "title": "Subcategoría"
          },
          {
            "field": "__1__",
            "type": "temporal",
            "title": "Periodo",
            "format": "%b %Y"
          },
          {
            "field": "ranking",
            "type": "quantitative",
            "title": "Puesto"
          },
          {
            "field": "__2__",
            "type": "quantitative",
            "title": "Ventas",
            "format": ",.0f"
          }
        ]
      }
    },
    {
      "description": "Etiqueta al final de cada línea: sustituye a la leyenda, sin saltos de vista.",
      "transform": [
        {
          "filter": "datum.pasoFinal === 1"
        }
      ],
      "mark": {
        "type": "text",
        "align": "left",
        "baseline": "middle",
        "dx": 14,
        "fontSize": 12.5,
        "fontWeight": 600
      },
      "encoding": {
        "text": {
          "field": "__0__",
          "type": "nominal"
        }
      }
    }
  ]
}
Get in touch!