Editorial arrow plot, 2014 to 2024
Dumbbell graphs display the relationship between two data points for multiple categories by connecting them with a line. It effectively shows the difference or change between these two values for each item, allowing for easy comparison of magnitudes and variations across the dataset. This visualization is useful for highlighting shifts or disparities.
<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" : "Dumbbell",
"dumbbellType" : "arrow",
"dumbbellArrowDirection" : "order",
"legendColumns" : 2,
"arrowHeadSize" : 8,
"xAxisTicks" : 4,
"smpTextScaleFontFactor" : 1.3,
"theme" : "editorial",
"colorScheme" : "User",
"title" : "Renewables have doubled their share in a decade",
"subtitle" : "Renewable share of electricity generation, 2014 → 2024, %",
"legendPosition" : "bottom",
"numberFormat" : {
"style" : "decimal",
"decimals" : 0,
"suffix" : "%"
},
"colors" : [
"#bbbbbb",
"#228833"
],
"xAxisTitle" : "",
"notes" : "Wind, solar, hydro and bioenergy. 2024 preliminary.",
"source" : "Ember",
"sourceUrl" : "https://ember-climate.org",
"byline" : "Chart: CanvasXpress",
"showDataDownload" : true,
"responsiveRules" : [
{
"maxWidth" : 480,
"config" : {
"legendPosition" : "bottom",
"fontScaleFontFactor" : 0.85,
"arrowHeadSize" : 5,
"connectByWidth" : 1
}
}
]
}
// 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" : [
"2014",
"2024"
],
"smps" : [
"Denmark",
"Germany",
"United Kingdom",
"Spain",
"United States",
"Japan",
"India"
],
"data" : [
[
48,
26,
18,
37,
13,
14,
15
],
[
81,
52,
46,
55,
23,
25,
22
]
]
}
}
// Create the configuration for the graph
var config = {
"graphType" : "Dumbbell",
"dumbbellType" : "arrow",
"dumbbellArrowDirection" : "order",
"legendColumns" : 2,
"arrowHeadSize" : 8,
"xAxisTicks" : 4,
"smpTextScaleFontFactor" : 1.3,
"theme" : "editorial",
"colorScheme" : "User",
"title" : "Renewables have doubled their share in a decade",
"subtitle" : "Renewable share of electricity generation, 2014 → 2024, %",
"legendPosition" : "bottom",
"numberFormat" : {
"style" : "decimal",
"decimals" : 0,
"suffix" : "%"
},
"colors" : [
"#bbbbbb",
"#228833"
],
"xAxisTitle" : "",
"notes" : "Wind, solar, hydro and bioenergy. 2024 preliminary.",
"source" : "Ember",
"sourceUrl" : "https://ember-climate.org",
"byline" : "Chart: CanvasXpress",
"showDataDownload" : true,
"responsiveRules" : [
{
"maxWidth" : 480,
"config" : {
"legendPosition" : "bottom",
"fontScaleFontFactor" : 0.85,
"arrowHeadSize" : 5,
"connectByWidth" : 1
}
}
]
}
// 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>
library(canvasXpress)
y=read.table("https://www.canvasxpress.org/data/r/cX-dumbbell17-dat.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
canvasXpress(
data=y,
arrowHeadSize=8,
byline="Chart: CanvasXpress",
colorScheme="User",
colors=list("#bbbbbb", "#228833"),
dumbbellArrowDirection="order",
dumbbellType="arrow",
graphType="Dumbbell",
legendColumns=2,
legendPosition="bottom",
notes="Wind, solar, hydro and bioenergy. 2024 preliminary.",
numberFormat=list(decimals=0, style="decimal", suffix="%"),
responsiveRules=list(list(config=list(arrowHeadSize=5, connectByWidth=1, fontScaleFontFactor=0.85, legendPosition="bottom"), maxWidth=480)),
showDataDownload=TRUE,
smpTextScaleFontFactor=1.3,
source="Ember",
sourceUrl="https://ember-climate.org",
subtitle="Renewable share of electricity generation, 2014 → 2024, %",
theme="editorial",
title="Renewables have doubled their share in a decade",
xAxisTicks=4,
xAxisTitle=""
)
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 = "dumbbell17",
data = {
"y": {
"vars": ["2014", "2024"],
"smps": ["Denmark", "Germany", "United Kingdom", "Spain", "United States", "Japan", "India"],
"data": [
[48, 26, 18, 37, 13, 14, 15],
[81, 52, 46, 55, 23, 25, 22]
]
}
},
config = {
"graphType": "Dumbbell",
"dumbbellType": "arrow",
"dumbbellArrowDirection": "order",
"legendColumns": 2,
"arrowHeadSize": 8,
"xAxisTicks": 4,
"smpTextScaleFontFactor": 1.3,
"theme": "editorial",
"colorScheme": "User",
"title": "Renewables have doubled their share in a decade",
"subtitle": "Renewable share of electricity generation, 2014 → 2024, %",
"legendPosition": "bottom",
"numberFormat": {
"style": "decimal",
"decimals": 0,
"suffix": "%"
},
"colors": ["#bbbbbb", "#228833"],
"xAxisTitle": "",
"notes": "Wind, solar, hydro and bioenergy. 2024 preliminary.",
"source": "Ember",
"sourceUrl": "https://ember-climate.org",
"byline": "Chart: CanvasXpress",
"showDataDownload": True,
"responsiveRules": [
{
"maxWidth": 480,
"config": {
"legendPosition": "bottom",
"fontScaleFontFactor": 0.85,
"arrowHeadSize": 5,
"connectByWidth": 1
}
}
]
},
width = 760,
height = 517
)
# 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 = "dumbbell17",
data = {
"y": {
"vars": ["2014", "2024"],
"smps": ["Denmark", "Germany", "United Kingdom", "Spain", "United States", "Japan", "India"],
"data": [
[48, 26, 18, 37, 13, 14, 15],
[81, 52, 46, 55, 23, 25, 22]
]
}
},
config = {
"graphType": "Dumbbell",
"dumbbellType": "arrow",
"dumbbellArrowDirection": "order",
"legendColumns": 2,
"arrowHeadSize": 8,
"xAxisTicks": 4,
"smpTextScaleFontFactor": 1.3,
"theme": "editorial",
"colorScheme": "User",
"title": "Renewables have doubled their share in a decade",
"subtitle": "Renewable share of electricity generation, 2014 → 2024, %",
"legendPosition": "bottom",
"numberFormat": {
"style": "decimal",
"decimals": 0,
"suffix": "%"
},
"colors": ["#bbbbbb", "#228833"],
"xAxisTitle": "",
"notes": "Wind, solar, hydro and bioenergy. 2024 preliminary.",
"source": "Ember",
"sourceUrl": "https://ember-climate.org",
"byline": "Chart: CanvasXpress",
"showDataDownload": True,
"responsiveRules": [
{
"maxWidth": 480,
"config": {
"legendPosition": "bottom",
"fontScaleFontFactor": 0.85,
"arrowHeadSize": 5,
"connectByWidth": 1
}
}
]
},
width = 760,
height = 517
)
)
using CanvasXpress
canvasxpress(Dict(
"y" => Dict(
"vars" => ["2014", "2024"],
"smps" => ["Denmark", "Germany", "United Kingdom", "Spain", "United States", "Japan", "India"],
"data" => [
[48, 26, 18, 37, 13, 14, 15],
[81, 52, 46, 55, 23, 25, 22]
]
)
);
graphType = "Dumbbell",
dumbbellType = "arrow",
dumbbellArrowDirection = "order",
legendColumns = 2,
arrowHeadSize = 8,
xAxisTicks = 4,
smpTextScaleFontFactor = 1.3,
theme = "editorial",
colorScheme = "User",
title = "Renewables have doubled their share in a decade",
subtitle = "Renewable share of electricity generation, 2014 → 2024, %",
legendPosition = "bottom",
numberFormat = Dict(
"style" => "decimal",
"decimals" => 0,
"suffix" => "%"
),
colors = ["#bbbbbb", "#228833"],
xAxisTitle = "",
notes = "Wind, solar, hydro and bioenergy. 2024 preliminary.",
source = "Ember",
sourceUrl = "https://ember-climate.org",
byline = "Chart: CanvasXpress",
showDataDownload = true,
responsiveRules = [
Dict(
"maxWidth" => 480,
"config" => Dict(
"legendPosition" => "bottom",
"fontScaleFontFactor" => 0.85,
"arrowHeadSize" => 5,
"connectByWidth" => 1
)
)
]
)
















