Editorial 100% stacked columns over six years

Time series charts in CanvasXpress show how values change over calendar time: annual, monthly and daily series as lines, step lines, areas, columns and small multiples, with confidence bands, projections, shaded periods, event callouts, dual axes and direct end labels. These examples recreate editorial chart idioms (the Datawrapper reference set) with synthetic data and publication-style themes; every one of them is an ordinary Scatter2D, Line, Area, AreaLine, Bar, BarLine or Stacked configuration, so the same options apply to your own dated data.


Economist GGPlot Excel Paul Tol Black And White Solarized Stata Tableau Wall Street CanvasXpress
<html>

  <head>
    <!-- Include the CanvasXpress library in your HTML file -->
    <link rel="stylesheet" href="https://www.canvasxpress.org/dist/canvasXpress.css" type="text/css"/>
    <script src="https://www.canvasxpress.org/dist/canvasXpress.min.js"></script>
  </head>

  <body>

    <!-- Create a canvas element for the chart with the desired dimensions -->
    <div>
      <canvas id="canvasId" width="600" height="600"></canvas>
    </div>


    <!-- Create a script to initialize the chart -->
    <script>

      // Use a data frame (2D-array) for the graph
      var data = 

      // Create the configuration for the graph
      var config = {
         "graphType" : "Stacked",
         "graphOrientation" : "vertical",
         "theme" : "editorial",
         "colorScheme" : "User",
         "title" : "Renewables are eating into coal and nuclear",
         "subtitle" : "World electricity generation by source, % of total",
         "legendPosition" : "bottom",
         "legendColumns" : 4,
         "numberFormat" : {
            "style" : "decimal",
            "decimals" : 0,
            "suffix" : "%"
         },
         "colors" : [
            "#555555",
            "#bbbbbb",
            "#ccbb44",
            "#228833"
         ],
         "xAxisTitle" : "",
         "smpTitle" : "",
         "notes" : "Other sources (oil, hydrogen) omitted; shares renormalised.",
         "source" : "IEA World Energy Outlook",
         "sourceUrl" : "https://www.iea.org",
         "byline" : "Chart: CanvasXpress",
         "showDataDownload" : true,
         "responsiveRules" : [
            {
               "maxWidth" : 480,
               "config" : {
                  "legendPosition" : "bottom",
                  "legendColumns" : 2,
                  "fontScaleFontFactor" : 0.85
               }
            }
         ]
      }

      // Event used to create graph (optional)
      var events = false

      // Call the CanvasXpress function to create the graph
      var cX = new CanvasXpress("canvasId", data, config, events);

    </script>

  </body>

</html>
<html>

  <head>
    <!-- Include the CanvasXpress library in your HTML file -->
    <link rel="stylesheet" href="https://www.canvasxpress.org/dist/canvasXpress.css" type="text/css"/>
    <script src="https://www.canvasxpress.org/dist/canvasXpress.min.js"></script>
  </head>

  <body>

    <!-- Create a canvas element for the chart with the desired dimensions -->
    <div>
      <canvas id="canvasId" width="600" height="600"></canvas>
    </div>


    <!-- Create a script to initialize the chart -->
    <script>

      // Create the data for the graph
      var data = {
         "y" : {
            "vars" : [
               "Coal",
               "Gas",
               "Nuclear",
               "Renewables"
            ],
            "smps" : [
               "2000 ",
               "2005 ",
               "2010 ",
               "2015 ",
               "2020 ",
               "2024 "
            ],
            "data" : [
               [
                  39,
                  41,
                  41,
                  39,
                  35,
                  34
               ],
               [
                  18,
                  20,
                  22,
                  23,
                  24,
                  23
               ],
               [
                  17,
                  15,
                  13,
                  11,
                  10,
                  9
               ],
               [
                  26,
                  24,
                  24,
                  27,
                  31,
                  34
               ]
            ]
         }
      }

      // Create the configuration for the graph
      var config = {
         "graphType" : "Stacked",
         "graphOrientation" : "vertical",
         "theme" : "editorial",
         "colorScheme" : "User",
         "title" : "Renewables are eating into coal and nuclear",
         "subtitle" : "World electricity generation by source, % of total",
         "legendPosition" : "bottom",
         "legendColumns" : 4,
         "numberFormat" : {
            "style" : "decimal",
            "decimals" : 0,
            "suffix" : "%"
         },
         "colors" : [
            "#555555",
            "#bbbbbb",
            "#ccbb44",
            "#228833"
         ],
         "xAxisTitle" : "",
         "smpTitle" : "",
         "notes" : "Other sources (oil, hydrogen) omitted; shares renormalised.",
         "source" : "IEA World Energy Outlook",
         "sourceUrl" : "https://www.iea.org",
         "byline" : "Chart: CanvasXpress",
         "showDataDownload" : true,
         "responsiveRules" : [
            {
               "maxWidth" : 480,
               "config" : {
                  "legendPosition" : "bottom",
                  "legendColumns" : 2,
                  "fontScaleFontFactor" : 0.85
               }
            }
         ]
      }

      // Event used to create graph (optional)
      var events = false

            // Call the CanvasXpress function to create the graph
      var cX = new CanvasXpress("canvasId", data, config, events);

    </script>

  </body>

</html>
from canvasxpress.canvas import CanvasXpress
from canvasxpress.plot import show_in_browser

if __name__ == "__main__":
  # Define the chart with its data and configuration
  chart: CanvasXpress = CanvasXpress(
    render_to = "timeseries22",
    data = {
      "y": {
        "vars": ["Coal", "Gas", "Nuclear", "Renewables"],
        "smps": ["2000 ", "2005 ", "2010 ", "2015 ", "2020 ", "2024 "],
        "data": [
          [39, 41, 41, 39, 35, 34],
          [18, 20, 22, 23, 24, 23],
          [17, 15, 13, 11, 10, 9],
          [26, 24, 24, 27, 31, 34]
        ]
      }
    },
    config = {
      "graphType": "Stacked",
      "graphOrientation": "vertical",
      "theme": "editorial",
      "colorScheme": "User",
      "title": "Renewables are eating into coal and nuclear",
      "subtitle": "World electricity generation by source, % of total",
      "legendPosition": "bottom",
      "legendColumns": 4,
      "numberFormat": {
        "style": "decimal",
        "decimals": 0,
        "suffix": "%"
      },
      "colors": ["#555555", "#bbbbbb", "#ccbb44", "#228833"],
      "xAxisTitle": "",
      "smpTitle": "",
      "notes": "Other sources (oil, hydrogen) omitted; shares renormalised.",
      "source": "IEA World Energy Outlook",
      "sourceUrl": "https://www.iea.org",
      "byline": "Chart: CanvasXpress",
      "showDataDownload": True,
      "responsiveRules": [
        {
          "maxWidth": 480,
          "config": {
            "legendPosition": "bottom",
            "legendColumns": 2,
            "fontScaleFontFactor": 0.85
          }
        }
      ]
    },
    width = 760,
    height = 517
  )

  # Display the chart in its own Web page
  show_in_browser(chart)
Run this notebook: Open in Binder
from canvasxpress.canvas import CanvasXpress
from canvasxpress.plot import graph

graph(
  CanvasXpress(
    render_to = "timeseries22",
    data = {
      "y": {
        "vars": ["Coal", "Gas", "Nuclear", "Renewables"],
        "smps": ["2000 ", "2005 ", "2010 ", "2015 ", "2020 ", "2024 "],
        "data": [
          [39, 41, 41, 39, 35, 34],
          [18, 20, 22, 23, 24, 23],
          [17, 15, 13, 11, 10, 9],
          [26, 24, 24, 27, 31, 34]
        ]
      }
    },
    config = {
      "graphType": "Stacked",
      "graphOrientation": "vertical",
      "theme": "editorial",
      "colorScheme": "User",
      "title": "Renewables are eating into coal and nuclear",
      "subtitle": "World electricity generation by source, % of total",
      "legendPosition": "bottom",
      "legendColumns": 4,
      "numberFormat": {
        "style": "decimal",
        "decimals": 0,
        "suffix": "%"
      },
      "colors": ["#555555", "#bbbbbb", "#ccbb44", "#228833"],
      "xAxisTitle": "",
      "smpTitle": "",
      "notes": "Other sources (oil, hydrogen) omitted; shares renormalised.",
      "source": "IEA World Energy Outlook",
      "sourceUrl": "https://www.iea.org",
      "byline": "Chart: CanvasXpress",
      "showDataDownload": True,
      "responsiveRules": [
        {
          "maxWidth": 480,
          "config": {
            "legendPosition": "bottom",
            "legendColumns": 2,
            "fontScaleFontFactor": 0.85
          }
        }
      ]
    },
    width = 760,
    height = 517
  )
)
using CanvasXpress

canvasxpress(Dict(
  "y" => Dict(
    "vars" => ["Coal", "Gas", "Nuclear", "Renewables"],
    "smps" => ["2000 ", "2005 ", "2010 ", "2015 ", "2020 ", "2024 "],
    "data" => [
      [39, 41, 41, 39, 35, 34],
      [18, 20, 22, 23, 24, 23],
      [17, 15, 13, 11, 10, 9],
      [26, 24, 24, 27, 31, 34]
    ]
  )
);
  graphType = "Stacked",
  graphOrientation = "vertical",
  theme = "editorial",
  colorScheme = "User",
  title = "Renewables are eating into coal and nuclear",
  subtitle = "World electricity generation by source, % of total",
  legendPosition = "bottom",
  legendColumns = 4,
  numberFormat = Dict(
    "style" => "decimal",
    "decimals" => 0,
    "suffix" => "%"
  ),
  colors = ["#555555", "#bbbbbb", "#ccbb44", "#228833"],
  xAxisTitle = "",
  smpTitle = "",
  notes = "Other sources (oil, hydrogen) omitted; shares renormalised.",
  source = "IEA World Energy Outlook",
  sourceUrl = "https://www.iea.org",
  byline = "Chart: CanvasXpress",
  showDataDownload = true,
  responsiveRules = [
    Dict(
      "maxWidth" => 480,
      "config" => Dict(
        "legendPosition" => "bottom",
        "legendColumns" => 2,
        "fontScaleFontFactor" => 0.85
      )
    )
  ]
)
⇧