Seven yearly values with a value label on each column
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.
<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" : "classic",
"xAxisGridMajorShow" : true,
"colorScheme" : "User",
"colors" : [
"#C8442E"
],
"xAxis" : [
"Hectares"
],
"showLegend" : false,
"title" : "In 7 years, 620,000 hectares of wetland drained",
"subtitle" : "Annual wetland area drained in the fictional Aldermere basin, in hectares.",
"xAxisNumberFormat" : "compact",
"smpTextRotate" : 90,
"smpTitle" : "",
"xAxisTitle" : "",
"sampleSpaceFactor" : 0.7
}
// 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" : [
"Hectares"
],
"smps" : [
"2016 ",
"2017 ",
"2018 ",
"2019 ",
"2020 ",
"2021 ",
"2022 "
],
"data" : [
[
18294,
23772,
46262,
86050,
161650,
163542,
66757
]
]
}
}
// Create the configuration for the graph
var config = {
"graphType" : "Bar",
"titleAlign" : "plot::0",
"subtitleAlign" : "plot::0",
"legendHorizontalJustification" : 0,
"legendJustifyTo" : "plot",
"graphOrientation" : "vertical",
"theme" : "classic",
"xAxisGridMajorShow" : true,
"colorScheme" : "User",
"colors" : [
"#C8442E"
],
"xAxis" : [
"Hectares"
],
"showLegend" : false,
"title" : "In 7 years, 620,000 hectares of wetland drained",
"subtitle" : "Annual wetland area drained in the fictional Aldermere basin, in hectares.",
"xAxisNumberFormat" : "compact",
"smpTextRotate" : 90,
"smpTitle" : "",
"xAxisTitle" : "",
"sampleSpaceFactor" : 0.7
}
// 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 = "timeseries16",
data = {
"y": {
"vars": ["Hectares"],
"smps": ["2016 ", "2017 ", "2018 ", "2019 ", "2020 ", "2021 ", "2022 "],
"data": [
[18294, 23772, 46262, 86050, 161650, 163542, 66757]
]
}
},
config = {
"graphType": "Bar",
"titleAlign": "plot::0",
"subtitleAlign": "plot::0",
"legendHorizontalJustification": 0,
"legendJustifyTo": "plot",
"graphOrientation": "vertical",
"theme": "classic",
"xAxisGridMajorShow": True,
"colorScheme": "User",
"colors": ["#C8442E"],
"xAxis": ["Hectares"],
"showLegend": False,
"title": "In 7 years, 620,000 hectares of wetland drained",
"subtitle": "Annual wetland area drained in the fictional Aldermere basin, in hectares.",
"xAxisNumberFormat": "compact",
"smpTextRotate": 90,
"smpTitle": "",
"xAxisTitle": "",
"sampleSpaceFactor": 0.7
},
width = 760,
height = 480
)
# Display the chart in its own Web page
show_in_browser(chart)
from canvasxpress.canvas import CanvasXpress
from canvasxpress.plot import graph
graph(
CanvasXpress(
render_to = "timeseries16",
data = {
"y": {
"vars": ["Hectares"],
"smps": ["2016 ", "2017 ", "2018 ", "2019 ", "2020 ", "2021 ", "2022 "],
"data": [
[18294, 23772, 46262, 86050, 161650, 163542, 66757]
]
}
},
config = {
"graphType": "Bar",
"titleAlign": "plot::0",
"subtitleAlign": "plot::0",
"legendHorizontalJustification": 0,
"legendJustifyTo": "plot",
"graphOrientation": "vertical",
"theme": "classic",
"xAxisGridMajorShow": True,
"colorScheme": "User",
"colors": ["#C8442E"],
"xAxis": ["Hectares"],
"showLegend": False,
"title": "In 7 years, 620,000 hectares of wetland drained",
"subtitle": "Annual wetland area drained in the fictional Aldermere basin, in hectares.",
"xAxisNumberFormat": "compact",
"smpTextRotate": 90,
"smpTitle": "",
"xAxisTitle": "",
"sampleSpaceFactor": 0.7
},
width = 760,
height = 480
)
)
using CanvasXpress
canvasxpress(Dict(
"y" => Dict(
"vars" => ["Hectares"],
"smps" => ["2016 ", "2017 ", "2018 ", "2019 ", "2020 ", "2021 ", "2022 "],
"data" => [
[18294, 23772, 46262, 86050, 161650, 163542, 66757]
]
)
);
graphType = "Bar",
titleAlign = "plot::0",
subtitleAlign = "plot::0",
legendHorizontalJustification = 0,
legendJustifyTo = "plot",
graphOrientation = "vertical",
theme = "classic",
xAxisGridMajorShow = true,
colorScheme = "User",
colors = ["#C8442E"],
xAxis = ["Hectares"],
showLegend = false,
title = "In 7 years, 620,000 hectares of wetland drained",
subtitle = "Annual wetland area drained in the fictional Aldermere basin, in hectares.",
xAxisNumberFormat = "compact",
smpTextRotate = 90,
smpTitle = "",
xAxisTitle = "",
sampleSpaceFactor = 0.7
)
























