Skip to content
Vega-Lite templates

Energy Mix — Generation by Source

Stacked bar of electricity generation by source across years.

Template previewVega-Lite
Rendering…

Make it your own.

{
  "$schema":"https://vega.github.io/schema/vega-lite/v5.json",
  "data":{"values":[
    {"y":2020,"src":"Coal","gw":580},{"y":2020,"src":"Gas","gw":420},{"y":2020,"src":"Nuclear","gw":210},{"y":2020,"src":"Hydro","gw":180},{"y":2020,"src":"Wind","gw":120},{"y":2020,"src":"Solar","gw":80},
    {"y":2021,"src":"Coal","gw":560},{"y":2021,"src":"Gas","gw":430},{"y":2021,"src":"Nuclear","gw":210},{"y":2021,"src":"Hydro","gw":185},{"y":2021,"src":"Wind","gw":150},{"y":2021,"src":"Solar","gw":110},
    {"y":2022,"src":"Coal","gw":510},{"y":2022,"src":"Gas","gw":440},{"y":2022,"src":"Nuclear","gw":215},{"y":2022,"src":"Hydro","gw":188},{"y":2022,"src":"Wind","gw":190},{"y":2022,"src":"Solar","gw":150},
    {"y":2023,"src":"Coal","gw":460},{"y":2023,"src":"Gas","gw":445},{"y":2023,"src":"Nuclear","gw":215},{"y":2023,"src":"Hydro","gw":190},{"y":2023,"src":"Wind","gw":240},{"y":2023,"src":"Solar","gw":210},
    {"y":2024,"src":"Coal","gw":420},{"y":2024,"src":"Gas","gw":450},{"y":2024,"src":"Nuclear","gw":220},{"y":2024,"src":"Hydro","gw":192},{"y":2024,"src":"Wind","gw":290},{"y":2024,"src":"Solar","gw":280}
  ]},
  "mark":"bar",
  "encoding":{
    "x":{"field":"y","type":"ordinal","title":"Year"},
    "y":{"field":"gw","type":"quantitative","title":"Generation (TWh)","stack":"zero"},
    "color":{"field":"src","type":"nominal",
      "scale":{"domain":["Coal","Gas","Nuclear","Hydro","Wind","Solar"],
               "range":["#525b66","#a16207","#7c3aed","#0ea5e9","#16a34a","#f59e0b"]}}
  },
  "width":480,"height":300
}