Annual counts with gap 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" : "Bar",
         "titleAlign" : "plot::0",
         "subtitleAlign" : "plot::0",
         "legendHorizontalJustification" : 0,
         "legendJustifyTo" : "plot",
         "graphOrientation" : "vertical",
         "theme" : "stata",
         "xAxisGridMajorShow" : true,
         "xAxisGridMajorColor" : "rgb(200,212,214)",
         "colorScheme" : "User",
         "colors" : [
            "#0B2B45"
         ],
         "title" : "Strong solar flares recorded by the Meridian Observatory",
         "subtitle" : "Number of X-class flares per year, 2000–2023. Several quiet years record none.",
         "xAxis" : [
            "Events"
         ],
         "showLegend" : false,
         "smpLabelInterval" : 5,
         "smpTextRotate" : 90,
         "smpTitle" : "",
         "xAxisTitle" : "",
         "sampleSpaceFactor" : 0.4
      }

      // 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" : [
               "Events"
            ],
            "smps" : [
               "’00",
               "’01",
               "’02",
               "’03",
               "’04",
               "’05",
               "’06",
               "’07",
               "’08",
               "’09",
               "’10",
               "’11",
               "’12",
               "’13",
               "’14",
               "’15",
               "’16",
               "’17",
               "’18",
               "’19",
               "’20",
               "’21",
               "’22",
               "’23"
            ],
            "data" : [
               [
                  1,
                  2,
                  0,
                  1,
                  0,
                  0,
                  0,
                  1,
                  2,
                  3,
                  1,
                  0,
                  2,
                  4,
                  1,
                  3,
                  0,
                  0,
                  1,
                  2,
                  2,
                  3,
                  1,
                  3
               ]
            ]
         }
      }

      // Create the configuration for the graph
      var config = {
         "graphType" : "Bar",
         "titleAlign" : "plot::0",
         "subtitleAlign" : "plot::0",
         "legendHorizontalJustification" : 0,
         "legendJustifyTo" : "plot",
         "graphOrientation" : "vertical",
         "theme" : "stata",
         "xAxisGridMajorShow" : true,
         "xAxisGridMajorColor" : "rgb(200,212,214)",
         "colorScheme" : "User",
         "colors" : [
            "#0B2B45"
         ],
         "title" : "Strong solar flares recorded by the Meridian Observatory",
         "subtitle" : "Number of X-class flares per year, 2000–2023. Several quiet years record none.",
         "xAxis" : [
            "Events"
         ],
         "showLegend" : false,
         "smpLabelInterval" : 5,
         "smpTextRotate" : 90,
         "smpTitle" : "",
         "xAxisTitle" : "",
         "sampleSpaceFactor" : 0.4
      }

      // 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 = "timeseries14",
    data = {
      "y": {
        "vars": ["Events"],
        "smps": ["’00", "’01", "’02", "’03", "’04", "’05", "’06", "’07", "’08", "’09", "’10", "’11", "’12", "’13", "’14", "’15", "’16", "’17", "’18", "’19", "’20", "’21", "’22", "’23"],
        "data": [
          [1, 2, 0, 1, 0, 0, 0, 1, 2, 3, 1, 0, 2, 4, 1, 3, 0, 0, 1, 2, 2, 3, 1, 3]
        ]
      }
    },
    config = {
      "graphType": "Bar",
      "titleAlign": "plot::0",
      "subtitleAlign": "plot::0",
      "legendHorizontalJustification": 0,
      "legendJustifyTo": "plot",
      "graphOrientation": "vertical",
      "theme": "stata",
      "xAxisGridMajorShow": True,
      "xAxisGridMajorColor": "rgb(200,212,214)",
      "colorScheme": "User",
      "colors": ["#0B2B45"],
      "title": "Strong solar flares recorded by the Meridian Observatory",
      "subtitle": "Number of X-class flares per year, 2000–2023. Several quiet years record none.",
      "xAxis": ["Events"],
      "showLegend": False,
      "smpLabelInterval": 5,
      "smpTextRotate": 90,
      "smpTitle": "",
      "xAxisTitle": "",
      "sampleSpaceFactor": 0.4
    },
    width = 760,
    height = 480
  )

  # 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 = "timeseries14",
    data = {
      "y": {
        "vars": ["Events"],
        "smps": ["’00", "’01", "’02", "’03", "’04", "’05", "’06", "’07", "’08", "’09", "’10", "’11", "’12", "’13", "’14", "’15", "’16", "’17", "’18", "’19", "’20", "’21", "’22", "’23"],
        "data": [
          [1, 2, 0, 1, 0, 0, 0, 1, 2, 3, 1, 0, 2, 4, 1, 3, 0, 0, 1, 2, 2, 3, 1, 3]
        ]
      }
    },
    config = {
      "graphType": "Bar",
      "titleAlign": "plot::0",
      "subtitleAlign": "plot::0",
      "legendHorizontalJustification": 0,
      "legendJustifyTo": "plot",
      "graphOrientation": "vertical",
      "theme": "stata",
      "xAxisGridMajorShow": True,
      "xAxisGridMajorColor": "rgb(200,212,214)",
      "colorScheme": "User",
      "colors": ["#0B2B45"],
      "title": "Strong solar flares recorded by the Meridian Observatory",
      "subtitle": "Number of X-class flares per year, 2000–2023. Several quiet years record none.",
      "xAxis": ["Events"],
      "showLegend": False,
      "smpLabelInterval": 5,
      "smpTextRotate": 90,
      "smpTitle": "",
      "xAxisTitle": "",
      "sampleSpaceFactor": 0.4
    },
    width = 760,
    height = 480
  )
)
using CanvasXpress

canvasxpress(Dict(
  "y" => Dict(
    "vars" => ["Events"],
    "smps" => ["’00", "’01", "’02", "’03", "’04", "’05", "’06", "’07", "’08", "’09", "’10", "’11", "’12", "’13", "’14", "’15", "’16", "’17", "’18", "’19", "’20", "’21", "’22", "’23"],
    "data" => [
      [1, 2, 0, 1, 0, 0, 0, 1, 2, 3, 1, 0, 2, 4, 1, 3, 0, 0, 1, 2, 2, 3, 1, 3]
    ]
  )
);
  graphType = "Bar",
  titleAlign = "plot::0",
  subtitleAlign = "plot::0",
  legendHorizontalJustification = 0,
  legendJustifyTo = "plot",
  graphOrientation = "vertical",
  theme = "stata",
  xAxisGridMajorShow = true,
  xAxisGridMajorColor = "rgb(200,212,214)",
  colorScheme = "User",
  colors = ["#0B2B45"],
  title = "Strong solar flares recorded by the Meridian Observatory",
  subtitle = "Number of X-class flares per year, 2000–2023. Several quiet years record none.",
  xAxis = ["Events"],
  showLegend = false,
  smpLabelInterval = 5,
  smpTextRotate = 90,
  smpTitle = "",
  xAxisTitle = "",
  sampleSpaceFactor = 0.4
)
⇧