Skip to content
Vega-Lite templates

Slope Chart

Two-period line per series — rank/value change between two time points.

Template previewVega-Lite
Rendering…

Make it your own.

{
  "$schema":"https://vega.github.io/schema/vega-lite/v5.json",
  "data":{"values":[
    {"year":2020,"country":"Norway","gdp":67},
    {"year":2024,"country":"Norway","gdp":89},
    {"year":2020,"country":"USA","gdp":63},
    {"year":2024,"country":"USA","gdp":80},
    {"year":2020,"country":"Germany","gdp":46},
    {"year":2024,"country":"Germany","gdp":54},
    {"year":2020,"country":"Japan","gdp":40},
    {"year":2024,"country":"Japan","gdp":33},
    {"year":2020,"country":"UK","gdp":42},
    {"year":2024,"country":"UK","gdp":49}
  ]},
  "mark":{"type":"line","point":true,"strokeWidth":2.5},
  "encoding":{
    "x":{"field":"year","type":"ordinal","title":null},
    "y":{"field":"gdp","type":"quantitative","title":"GDP per capita (k$)"},
    "color":{"field":"country","type":"nominal"}
  },
  "width":260,"height":300
}