Editorial line chart with a callout and end labels

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" : "Line",
         "graphOrientation" : "vertical",
         "theme" : "editorial",
         "colorScheme" : "User",
         "title" : "Unemployment keeps falling in southern Europe",
         "colors" : [
            "#4477aa",
            "#ee6677",
            "#ccbb44",
            "#228833"
         ],
         "subtitle" : "Unemployment rate, % of labour force, annual average",
         "showLegend" : false,
         "showLineEndLabels" : true,
         "dataTextScaleFontFactor" : 0.8,
         "numberFormat" : {
            "style" : "decimal",
            "decimals" : 0,
            "suffix" : "%"
         },
         "tooltipNumberFormat" : {
            "style" : "decimal",
            "decimals" : 1,
            "suffix" : "%"
         },
         "yAxisTitle" : "",
         "xAxisTitle" : "",
         "decorations" : {
            "marker" : [
               {
                  "text" : "Pandemic spike",
                  "variable" : "Spain",
                  "sample" : "2020 ",
                  "type" : "curved",
                  "x" : 0.62,
                  "y" : 0.18
               }
            ]
         },
         "notes" : "Annual averages; 2024 provisional.",
         "source" : "Eurostat",
         "sourceUrl" : "https://ec.europa.eu/eurostat",
         "byline" : "Chart: CanvasXpress",
         "showDataDownload" : true,
         "responsiveRules" : [
            {
               "maxWidth" : 480,
               "config" : {
                  "legendPosition" : "bottom",
                  "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" : [
               "Spain",
               "Italy",
               "France",
               "Germany"
            ],
            "smps" : [
               "2015 ",
               "2016 ",
               "2017 ",
               "2018 ",
               "2019 ",
               "2020 ",
               "2021 ",
               "2022 ",
               "2023 ",
               "2024 "
            ],
            "data" : [
               [
                  22.1,
                  19.6,
                  17.2,
                  15.3,
                  14.1,
                  15.5,
                  14.8,
                  12.9,
                  12.1,
                  11.4
               ],
               [
                  11.9,
                  11.7,
                  11.2,
                  10.6,
                  10,
                  9.2,
                  9.5,
                  8.1,
                  7.7,
                  6.5
               ],
               [
                  10.4,
                  10.1,
                  9.4,
                  9,
                  8.4,
                  8,
                  7.9,
                  7.3,
                  7.3,
                  7.4
               ],
               [
                  4.6,
                  4.1,
                  3.8,
                  3.4,
                  3.2,
                  3.8,
                  3.6,
                  3.1,
                  3,
                  3.4
               ]
            ]
         }
      }

      // Create the configuration for the graph
      var config = {
         "graphType" : "Line",
         "graphOrientation" : "vertical",
         "theme" : "editorial",
         "colorScheme" : "User",
         "title" : "Unemployment keeps falling in southern Europe",
         "colors" : [
            "#4477aa",
            "#ee6677",
            "#ccbb44",
            "#228833"
         ],
         "subtitle" : "Unemployment rate, % of labour force, annual average",
         "showLegend" : false,
         "showLineEndLabels" : true,
         "dataTextScaleFontFactor" : 0.8,
         "numberFormat" : {
            "style" : "decimal",
            "decimals" : 0,
            "suffix" : "%"
         },
         "tooltipNumberFormat" : {
            "style" : "decimal",
            "decimals" : 1,
            "suffix" : "%"
         },
         "yAxisTitle" : "",
         "xAxisTitle" : "",
         "decorations" : {
            "marker" : [
               {
                  "text" : "Pandemic spike",
                  "variable" : "Spain",
                  "sample" : "2020 ",
                  "type" : "curved",
                  "x" : 0.62,
                  "y" : 0.18
               }
            ]
         },
         "notes" : "Annual averages; 2024 provisional.",
         "source" : "Eurostat",
         "sourceUrl" : "https://ec.europa.eu/eurostat",
         "byline" : "Chart: CanvasXpress",
         "showDataDownload" : true,
         "responsiveRules" : [
            {
               "maxWidth" : 480,
               "config" : {
                  "legendPosition" : "bottom",
                  "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 = "timeseries20",
    data = {
      "y": {
        "vars": ["Spain", "Italy", "France", "Germany"],
        "smps": ["2015 ", "2016 ", "2017 ", "2018 ", "2019 ", "2020 ", "2021 ", "2022 ", "2023 ", "2024 "],
        "data": [
          [22.1, 19.6, 17.2, 15.3, 14.1, 15.5, 14.8, 12.9, 12.1, 11.4],
          [11.9, 11.7, 11.2, 10.6, 10, 9.2, 9.5, 8.1, 7.7, 6.5],
          [10.4, 10.1, 9.4, 9, 8.4, 8, 7.9, 7.3, 7.3, 7.4],
          [4.6, 4.1, 3.8, 3.4, 3.2, 3.8, 3.6, 3.1, 3, 3.4]
        ]
      }
    },
    config = {
      "graphType": "Line",
      "graphOrientation": "vertical",
      "theme": "editorial",
      "colorScheme": "User",
      "title": "Unemployment keeps falling in southern Europe",
      "colors": ["#4477aa", "#ee6677", "#ccbb44", "#228833"],
      "subtitle": "Unemployment rate, % of labour force, annual average",
      "showLegend": False,
      "showLineEndLabels": True,
      "dataTextScaleFontFactor": 0.8,
      "numberFormat": {
        "style": "decimal",
        "decimals": 0,
        "suffix": "%"
      },
      "tooltipNumberFormat": {
        "style": "decimal",
        "decimals": 1,
        "suffix": "%"
      },
      "yAxisTitle": "",
      "xAxisTitle": "",
      "decorations": {
        "marker": [
          {
            "text": "Pandemic spike",
            "variable": "Spain",
            "sample": "2020 ",
            "type": "curved",
            "x": 0.62,
            "y": 0.18
          }
        ]
      },
      "notes": "Annual averages; 2024 provisional.",
      "source": "Eurostat",
      "sourceUrl": "https://ec.europa.eu/eurostat",
      "byline": "Chart: CanvasXpress",
      "showDataDownload": True,
      "responsiveRules": [
        {
          "maxWidth": 480,
          "config": {
            "legendPosition": "bottom",
            "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 = "timeseries20",
    data = {
      "y": {
        "vars": ["Spain", "Italy", "France", "Germany"],
        "smps": ["2015 ", "2016 ", "2017 ", "2018 ", "2019 ", "2020 ", "2021 ", "2022 ", "2023 ", "2024 "],
        "data": [
          [22.1, 19.6, 17.2, 15.3, 14.1, 15.5, 14.8, 12.9, 12.1, 11.4],
          [11.9, 11.7, 11.2, 10.6, 10, 9.2, 9.5, 8.1, 7.7, 6.5],
          [10.4, 10.1, 9.4, 9, 8.4, 8, 7.9, 7.3, 7.3, 7.4],
          [4.6, 4.1, 3.8, 3.4, 3.2, 3.8, 3.6, 3.1, 3, 3.4]
        ]
      }
    },
    config = {
      "graphType": "Line",
      "graphOrientation": "vertical",
      "theme": "editorial",
      "colorScheme": "User",
      "title": "Unemployment keeps falling in southern Europe",
      "colors": ["#4477aa", "#ee6677", "#ccbb44", "#228833"],
      "subtitle": "Unemployment rate, % of labour force, annual average",
      "showLegend": False,
      "showLineEndLabels": True,
      "dataTextScaleFontFactor": 0.8,
      "numberFormat": {
        "style": "decimal",
        "decimals": 0,
        "suffix": "%"
      },
      "tooltipNumberFormat": {
        "style": "decimal",
        "decimals": 1,
        "suffix": "%"
      },
      "yAxisTitle": "",
      "xAxisTitle": "",
      "decorations": {
        "marker": [
          {
            "text": "Pandemic spike",
            "variable": "Spain",
            "sample": "2020 ",
            "type": "curved",
            "x": 0.62,
            "y": 0.18
          }
        ]
      },
      "notes": "Annual averages; 2024 provisional.",
      "source": "Eurostat",
      "sourceUrl": "https://ec.europa.eu/eurostat",
      "byline": "Chart: CanvasXpress",
      "showDataDownload": True,
      "responsiveRules": [
        {
          "maxWidth": 480,
          "config": {
            "legendPosition": "bottom",
            "fontScaleFontFactor": 0.85
          }
        }
      ]
    },
    width = 760,
    height = 517
  )
)
using CanvasXpress

canvasxpress(Dict(
  "y" => Dict(
    "vars" => ["Spain", "Italy", "France", "Germany"],
    "smps" => ["2015 ", "2016 ", "2017 ", "2018 ", "2019 ", "2020 ", "2021 ", "2022 ", "2023 ", "2024 "],
    "data" => [
      [22.1, 19.6, 17.2, 15.3, 14.1, 15.5, 14.8, 12.9, 12.1, 11.4],
      [11.9, 11.7, 11.2, 10.6, 10, 9.2, 9.5, 8.1, 7.7, 6.5],
      [10.4, 10.1, 9.4, 9, 8.4, 8, 7.9, 7.3, 7.3, 7.4],
      [4.6, 4.1, 3.8, 3.4, 3.2, 3.8, 3.6, 3.1, 3, 3.4]
    ]
  )
);
  graphType = "Line",
  graphOrientation = "vertical",
  theme = "editorial",
  colorScheme = "User",
  title = "Unemployment keeps falling in southern Europe",
  colors = ["#4477aa", "#ee6677", "#ccbb44", "#228833"],
  subtitle = "Unemployment rate, % of labour force, annual average",
  showLegend = false,
  showLineEndLabels = true,
  dataTextScaleFontFactor = 0.8,
  numberFormat = Dict(
    "style" => "decimal",
    "decimals" => 0,
    "suffix" => "%"
  ),
  tooltipNumberFormat = Dict(
    "style" => "decimal",
    "decimals" => 1,
    "suffix" => "%"
  ),
  yAxisTitle = "",
  xAxisTitle = "",
  decorations = Dict(
    "marker" => [
      Dict(
        "text" => "Pandemic spike",
        "variable" => "Spain",
        "sample" => "2020 ",
        "type" => "curved",
        "x" => 0.62,
        "y" => 0.18
      )
    ]
  ),
  notes = "Annual averages; 2024 provisional.",
  source = "Eurostat",
  sourceUrl = "https://ec.europa.eu/eurostat",
  byline = "Chart: CanvasXpress",
  showDataDownload = true,
  responsiveRules = [
    Dict(
      "maxWidth" => 480,
      "config" => Dict(
        "legendPosition" => "bottom",
        "fontScaleFontFactor" => 0.85
      )
    )
  ]
)
⇧