Single smooth area with a shaded period and dotted baseline
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" : "Area",
"graphOrientation" : "vertical",
"theme" : "minimal",
"lineType" : "spline",
"xAxis" : [
"Lake level above present (m)"
],
"colorScheme" : "User",
"colors" : [
"#8FB3C2"
],
"objectColorTransparency" : 0.6,
"title" : "Rising and falling lake levels in the Chad basin",
"subtitle" : "Lake surface elevation, meters above the present level",
"smpTitle" : false,
"smpLabelInterval" : 4,
"smpTextRotate" : 90,
"xAxisTitle" : false,
"showLegend" : false,
"setMinX" : 0,
"setMaxX" : 36,
"marginRight" : 22,
"decorations" : {
"range" : [
{
"smp" : "9.5 ka",
"smp2" : "5.5 ka",
"color" : "rgba(240,160,60,0.22)"
}
],
"line" : [
{
"value" : 10.5,
"color" : "#1B7F9E",
"width" : 3,
"label" : "Present-day level",
"align" : "left",
"type" : "dotted"
}
],
"marker" : [
{
"text" : "Shorelines mapped\nduring the humid period",
"variable" : "Lake level above present (m)",
"sample" : "7.5 ka",
"type" : "arrow",
"x" : 0.52,
"y" : 0.32
},
{
"text" : "African Humid Period",
"variable" : "Lake level above present (m)",
"sample" : "7.5 ka",
"type" : "text",
"x" : 0.4,
"y" : 0.17,
"color" : "#9A6A1A"
}
]
},
"byline" : "Chart: CanvasXpress",
"source" : "Synthetic data for illustration"
}
// 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" : [
"Lake level above present (m)"
],
"smps" : [
"12 ka",
"11.5 ka",
"11 ka",
"10.5 ka",
"10 ka",
"9.5 ka",
"9 ka",
"8.5 ka",
"8 ka",
"7.5 ka",
"7 ka",
"6.5 ka",
"6 ka",
"5.5 ka",
"5 ka",
"4.5 ka",
"4 ka",
"3.5 ka",
"3 ka",
"2.5 ka",
"2 ka",
"1.5 ka",
"1 ka",
"0.5 ka",
"0 ka"
],
"data" : [
[
34,
31,
26,
21.5,
17.2,
14.6,
12.3,
11.2,
11.6,
10.4,
7.6,
5.2,
3.9,
3.4,
3.6,
4.9,
6.3,
7.5,
8.4,
9,
9.4,
9.8,
10.1,
10.4,
10.6
]
]
}
}
// Create the configuration for the graph
var config = {
"graphType" : "Area",
"graphOrientation" : "vertical",
"theme" : "minimal",
"lineType" : "spline",
"xAxis" : [
"Lake level above present (m)"
],
"colorScheme" : "User",
"colors" : [
"#8FB3C2"
],
"objectColorTransparency" : 0.6,
"title" : "Rising and falling lake levels in the Chad basin",
"subtitle" : "Lake surface elevation, meters above the present level",
"smpTitle" : false,
"smpLabelInterval" : 4,
"smpTextRotate" : 90,
"xAxisTitle" : false,
"showLegend" : false,
"setMinX" : 0,
"setMaxX" : 36,
"marginRight" : 22,
"decorations" : {
"range" : [
{
"smp" : "9.5 ka",
"smp2" : "5.5 ka",
"color" : "rgba(240,160,60,0.22)"
}
],
"line" : [
{
"value" : 10.5,
"color" : "#1B7F9E",
"width" : 3,
"label" : "Present-day level",
"align" : "left",
"type" : "dotted"
}
],
"marker" : [
{
"text" : "Shorelines mapped\nduring the humid period",
"variable" : "Lake level above present (m)",
"sample" : "7.5 ka",
"type" : "arrow",
"x" : 0.52,
"y" : 0.32
},
{
"text" : "African Humid Period",
"variable" : "Lake level above present (m)",
"sample" : "7.5 ka",
"type" : "text",
"x" : 0.4,
"y" : 0.17,
"color" : "#9A6A1A"
}
]
},
"byline" : "Chart: CanvasXpress",
"source" : "Synthetic data for illustration"
}
// 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 = "timeseries11",
data = {
"y": {
"vars": ["Lake level above present (m)"],
"smps": ["12 ka", "11.5 ka", "11 ka", "10.5 ka", "10 ka", "9.5 ka", "9 ka", "8.5 ka", "8 ka", "7.5 ka", "7 ka", "6.5 ka", "6 ka", "5.5 ka", "5 ka", "4.5 ka", "4 ka", "3.5 ka", "3 ka", "2.5 ka", "2 ka", "1.5 ka", "1 ka", "0.5 ka", "0 ka"],
"data": [
[34, 31, 26, 21.5, 17.2, 14.6, 12.3, 11.2, 11.6, 10.4, 7.6, 5.2, 3.9, 3.4, 3.6, 4.9, 6.3, 7.5, 8.4, 9, 9.4, 9.8, 10.1, 10.4, 10.6]
]
}
},
config = {
"graphType": "Area",
"graphOrientation": "vertical",
"theme": "minimal",
"lineType": "spline",
"xAxis": ["Lake level above present (m)"],
"colorScheme": "User",
"colors": ["#8FB3C2"],
"objectColorTransparency": 0.6,
"title": "Rising and falling lake levels in the Chad basin",
"subtitle": "Lake surface elevation, meters above the present level",
"smpTitle": False,
"smpLabelInterval": 4,
"smpTextRotate": 90,
"xAxisTitle": False,
"showLegend": False,
"setMinX": 0,
"setMaxX": 36,
"marginRight": 22,
"decorations": {
"range": [
{
"smp": "9.5 ka",
"smp2": "5.5 ka",
"color": "rgba(240,160,60,0.22)"
}
],
"line": [
{
"value": 10.5,
"color": "#1B7F9E",
"width": 3,
"label": "Present-day level",
"align": "left",
"type": "dotted"
}
],
"marker": [
{
"text": "Shorelines mapped\nduring the humid period",
"variable": "Lake level above present (m)",
"sample": "7.5 ka",
"type": "arrow",
"x": 0.52,
"y": 0.32
},
{
"text": "African Humid Period",
"variable": "Lake level above present (m)",
"sample": "7.5 ka",
"type": "text",
"x": 0.4,
"y": 0.17,
"color": "#9A6A1A"
}
]
},
"byline": "Chart: CanvasXpress",
"source": "Synthetic data for illustration"
},
width = 760,
height = 560
)
# 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 = "timeseries11",
data = {
"y": {
"vars": ["Lake level above present (m)"],
"smps": ["12 ka", "11.5 ka", "11 ka", "10.5 ka", "10 ka", "9.5 ka", "9 ka", "8.5 ka", "8 ka", "7.5 ka", "7 ka", "6.5 ka", "6 ka", "5.5 ka", "5 ka", "4.5 ka", "4 ka", "3.5 ka", "3 ka", "2.5 ka", "2 ka", "1.5 ka", "1 ka", "0.5 ka", "0 ka"],
"data": [
[34, 31, 26, 21.5, 17.2, 14.6, 12.3, 11.2, 11.6, 10.4, 7.6, 5.2, 3.9, 3.4, 3.6, 4.9, 6.3, 7.5, 8.4, 9, 9.4, 9.8, 10.1, 10.4, 10.6]
]
}
},
config = {
"graphType": "Area",
"graphOrientation": "vertical",
"theme": "minimal",
"lineType": "spline",
"xAxis": ["Lake level above present (m)"],
"colorScheme": "User",
"colors": ["#8FB3C2"],
"objectColorTransparency": 0.6,
"title": "Rising and falling lake levels in the Chad basin",
"subtitle": "Lake surface elevation, meters above the present level",
"smpTitle": False,
"smpLabelInterval": 4,
"smpTextRotate": 90,
"xAxisTitle": False,
"showLegend": False,
"setMinX": 0,
"setMaxX": 36,
"marginRight": 22,
"decorations": {
"range": [
{
"smp": "9.5 ka",
"smp2": "5.5 ka",
"color": "rgba(240,160,60,0.22)"
}
],
"line": [
{
"value": 10.5,
"color": "#1B7F9E",
"width": 3,
"label": "Present-day level",
"align": "left",
"type": "dotted"
}
],
"marker": [
{
"text": "Shorelines mapped\nduring the humid period",
"variable": "Lake level above present (m)",
"sample": "7.5 ka",
"type": "arrow",
"x": 0.52,
"y": 0.32
},
{
"text": "African Humid Period",
"variable": "Lake level above present (m)",
"sample": "7.5 ka",
"type": "text",
"x": 0.4,
"y": 0.17,
"color": "#9A6A1A"
}
]
},
"byline": "Chart: CanvasXpress",
"source": "Synthetic data for illustration"
},
width = 760,
height = 560
)
)
using CanvasXpress
canvasxpress(Dict(
"y" => Dict(
"vars" => ["Lake level above present (m)"],
"smps" => ["12 ka", "11.5 ka", "11 ka", "10.5 ka", "10 ka", "9.5 ka", "9 ka", "8.5 ka", "8 ka", "7.5 ka", "7 ka", "6.5 ka", "6 ka", "5.5 ka", "5 ka", "4.5 ka", "4 ka", "3.5 ka", "3 ka", "2.5 ka", "2 ka", "1.5 ka", "1 ka", "0.5 ka", "0 ka"],
"data" => [
[34, 31, 26, 21.5, 17.2, 14.6, 12.3, 11.2, 11.6, 10.4, 7.6, 5.2, 3.9, 3.4, 3.6, 4.9, 6.3, 7.5, 8.4, 9, 9.4, 9.8, 10.1, 10.4, 10.6]
]
)
);
graphType = "Area",
graphOrientation = "vertical",
theme = "minimal",
lineType = "spline",
xAxis = ["Lake level above present (m)"],
colorScheme = "User",
colors = ["#8FB3C2"],
objectColorTransparency = 0.6,
title = "Rising and falling lake levels in the Chad basin",
subtitle = "Lake surface elevation, meters above the present level",
smpTitle = false,
smpLabelInterval = 4,
smpTextRotate = 90,
xAxisTitle = false,
showLegend = false,
setMinX = 0,
setMaxX = 36,
marginRight = 22,
decorations = Dict(
"range" => [
Dict(
"smp" => "9.5 ka",
"smp2" => "5.5 ka",
"color" => "rgba(240,160,60,0.22)"
)
],
"line" => [
Dict(
"value" => 10.5,
"color" => "#1B7F9E",
"width" => 3,
"label" => "Present-day level",
"align" => "left",
"type" => "dotted"
)
],
"marker" => [
Dict(
"text" => "Shorelines mapped\nduring the humid period",
"variable" => "Lake level above present (m)",
"sample" => "7.5 ka",
"type" => "arrow",
"x" => 0.52,
"y" => 0.32
),
Dict(
"text" => "African Humid Period",
"variable" => "Lake level above present (m)",
"sample" => "7.5 ka",
"type" => "text",
"x" => 0.4,
"y" => 0.17,
"color" => "#9A6A1A"
)
]
),
byline = "Chart: CanvasXpress",
source = "Synthetic data for illustration"
)
























