Categorical choropleth of Europe
Maps in CanvasXpress allow users to create interactive and customizable visualizations for geographical data. You can integrate various map types, such as choropleths or point maps, and layer your data to highlight trends, distributions, or relationships across regions. With its flexibility, Maps in CanvasXpress support detailed analysis and presentation of spatial data for a wide range of applications.
<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" : "Map",
"topoJSON" : "https://www.canvasxpress.org/data/maps/EUROPE.json",
"mapId" : "europeGroups",
"theme" : "minimal",
"colorBy" : "Group",
"colorScheme" : "User",
"colors" : [
"#cc6677",
"#332288",
"#44aa99",
"#ddcc77",
"#dddddd"
],
"legendOrder" : {
"Group" : [
"Care-home residents",
"Essential workers",
"Health-care staff",
"Campaign planned",
"Not yet available"
]
},
"legendPosition" : "topRight",
"legendInside" : true,
"title" : "Who gets the first dose?",
"subtitle" : "Invented priority groups by country",
"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" : [
"ISL",
"NOR",
"SWE",
"FIN",
"EST",
"LVA",
"LTU",
"DNK",
"IRL",
"GBR",
"NLD",
"BEL",
"DEU",
"POL",
"CZE",
"SVK",
"AUT",
"CHE",
"FRA",
"ESP",
"PRT",
"ITA",
"HUN",
"ROU",
"BGR",
"SRB",
"GRC",
"HRV",
"SVN",
"UKR",
"BLR",
"MDA",
"ALB",
"BIH",
"MKD",
"MNE",
"LUX",
"CYP",
"LIE",
"SMR",
"MCO",
"AND",
"VAT",
"MLT",
"RUS",
"GIB",
"FRO",
"JEY",
"GGY",
"IMN"
],
"smps" : [
"Priority"
],
"data" : [
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
]
]
},
"z" : {
"Group" : [
"Care-home residents",
"Care-home residents",
"Care-home residents",
"Health-care staff",
"Health-care staff",
"Health-care staff",
"Health-care staff",
"Care-home residents",
"Care-home residents",
"Care-home residents",
"Campaign planned",
"Care-home residents",
"Care-home residents",
"Health-care staff",
"Essential workers",
"Health-care staff",
"Care-home residents",
"Care-home residents",
"Care-home residents",
"Care-home residents",
"Health-care staff",
"Health-care staff",
"Health-care staff",
"Health-care staff",
"Essential workers",
"Essential workers",
"Health-care staff",
"Care-home residents",
"Care-home residents",
"Not yet available",
"Not yet available",
"Not yet available",
"Not yet available",
"Not yet available",
"Not yet available",
"Not yet available",
"Campaign planned",
"Health-care staff",
"Not yet available",
"Not yet available",
"Not yet available",
"Not yet available",
"Not yet available",
"Not yet available",
"Not yet available",
"Not yet available",
"Not yet available",
"Not yet available",
"Not yet available",
"Not yet available"
]
}
}
// Create the configuration for the graph
var config = {
"graphType" : "Map",
"topoJSON" : "https://www.canvasxpress.org/data/maps/EUROPE.json",
"mapId" : "europeGroups",
"theme" : "minimal",
"colorBy" : "Group",
"colorScheme" : "User",
"colors" : [
"#cc6677",
"#332288",
"#44aa99",
"#ddcc77",
"#dddddd"
],
"legendOrder" : {
"Group" : [
"Care-home residents",
"Essential workers",
"Health-care staff",
"Campaign planned",
"Not yet available"
]
},
"legendPosition" : "topRight",
"legendInside" : true,
"title" : "Who gets the first dose?",
"subtitle" : "Invented priority groups by country",
"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>
library(canvasXpress)
y=read.table("https://www.canvasxpress.org/data/r/cX-map25-dat.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
z=read.table("https://www.canvasxpress.org/data/r/cX-map25-var.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
canvasXpress(
data=y,
varAnnot=z,
colorBy="Group",
colorScheme="User",
colors=list("#cc6677", "#332288", "#44aa99", "#ddcc77", "#dddddd"),
graphType="Map",
legendInside=TRUE,
legendOrder=list(Group=list("Care-home residents", "Essential workers", "Health-care staff", "Campaign planned", "Not yet available")),
legendPosition="topRight",
mapId="europeGroups",
source="Synthetic data for illustration",
subtitle="Invented priority groups by country",
theme="minimal",
title="Who gets the first dose?",
topoJSON="https://www.canvasxpress.org/data/maps/EUROPE.json"
)
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 = "map24",
data = {
"y": {
"vars": ["ISL", "NOR", "SWE", "FIN", "EST", "LVA", "LTU", "DNK", "IRL", "GBR", "NLD", "BEL", "DEU", "POL", "CZE", "SVK", "AUT", "CHE", "FRA", "ESP", "PRT", "ITA", "HUN", "ROU", "BGR", "SRB", "GRC", "HRV", "SVN", "UKR", "BLR", "MDA", "ALB", "BIH", "MKD", "MNE", "LUX", "CYP", "LIE", "SMR", "MCO", "AND", "VAT", "MLT", "RUS", "GIB", "FRO", "JEY", "GGY", "IMN"],
"smps": ["Priority"],
"data": [
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1]
]
},
"z": {
"Group": ["Care-home residents", "Care-home residents", "Care-home residents", "Health-care staff", "Health-care staff", "Health-care staff", "Health-care staff", "Care-home residents", "Care-home residents", "Care-home residents", "Campaign planned", "Care-home residents", "Care-home residents", "Health-care staff", "Essential workers", "Health-care staff", "Care-home residents", "Care-home residents", "Care-home residents", "Care-home residents", "Health-care staff", "Health-care staff", "Health-care staff", "Health-care staff", "Essential workers", "Essential workers", "Health-care staff", "Care-home residents", "Care-home residents", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Campaign planned", "Health-care staff", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available"]
}
},
config = {
"graphType": "Map",
"topoJSON": "https://www.canvasxpress.org/data/maps/EUROPE.json",
"mapId": "europeGroups",
"theme": "minimal",
"colorBy": "Group",
"colorScheme": "User",
"colors": ["#cc6677", "#332288", "#44aa99", "#ddcc77", "#dddddd"],
"legendOrder": {
"Group": ["Care-home residents", "Essential workers", "Health-care staff", "Campaign planned", "Not yet available"]
},
"legendPosition": "topRight",
"legendInside": True,
"title": "Who gets the first dose?",
"subtitle": "Invented priority groups by country",
"source": "Synthetic data for illustration"
},
width = 760,
height = 600
)
# 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 = "map24",
data = {
"y": {
"vars": ["ISL", "NOR", "SWE", "FIN", "EST", "LVA", "LTU", "DNK", "IRL", "GBR", "NLD", "BEL", "DEU", "POL", "CZE", "SVK", "AUT", "CHE", "FRA", "ESP", "PRT", "ITA", "HUN", "ROU", "BGR", "SRB", "GRC", "HRV", "SVN", "UKR", "BLR", "MDA", "ALB", "BIH", "MKD", "MNE", "LUX", "CYP", "LIE", "SMR", "MCO", "AND", "VAT", "MLT", "RUS", "GIB", "FRO", "JEY", "GGY", "IMN"],
"smps": ["Priority"],
"data": [
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1]
]
},
"z": {
"Group": ["Care-home residents", "Care-home residents", "Care-home residents", "Health-care staff", "Health-care staff", "Health-care staff", "Health-care staff", "Care-home residents", "Care-home residents", "Care-home residents", "Campaign planned", "Care-home residents", "Care-home residents", "Health-care staff", "Essential workers", "Health-care staff", "Care-home residents", "Care-home residents", "Care-home residents", "Care-home residents", "Health-care staff", "Health-care staff", "Health-care staff", "Health-care staff", "Essential workers", "Essential workers", "Health-care staff", "Care-home residents", "Care-home residents", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Campaign planned", "Health-care staff", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available"]
}
},
config = {
"graphType": "Map",
"topoJSON": "https://www.canvasxpress.org/data/maps/EUROPE.json",
"mapId": "europeGroups",
"theme": "minimal",
"colorBy": "Group",
"colorScheme": "User",
"colors": ["#cc6677", "#332288", "#44aa99", "#ddcc77", "#dddddd"],
"legendOrder": {
"Group": ["Care-home residents", "Essential workers", "Health-care staff", "Campaign planned", "Not yet available"]
},
"legendPosition": "topRight",
"legendInside": True,
"title": "Who gets the first dose?",
"subtitle": "Invented priority groups by country",
"source": "Synthetic data for illustration"
},
width = 760,
height = 600
)
)
using CanvasXpress
canvasxpress(Dict(
"y" => Dict(
"vars" => ["ISL", "NOR", "SWE", "FIN", "EST", "LVA", "LTU", "DNK", "IRL", "GBR", "NLD", "BEL", "DEU", "POL", "CZE", "SVK", "AUT", "CHE", "FRA", "ESP", "PRT", "ITA", "HUN", "ROU", "BGR", "SRB", "GRC", "HRV", "SVN", "UKR", "BLR", "MDA", "ALB", "BIH", "MKD", "MNE", "LUX", "CYP", "LIE", "SMR", "MCO", "AND", "VAT", "MLT", "RUS", "GIB", "FRO", "JEY", "GGY", "IMN"],
"smps" => ["Priority"],
"data" => [
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1]
]
),
"z" => Dict(
"Group" => ["Care-home residents", "Care-home residents", "Care-home residents", "Health-care staff", "Health-care staff", "Health-care staff", "Health-care staff", "Care-home residents", "Care-home residents", "Care-home residents", "Campaign planned", "Care-home residents", "Care-home residents", "Health-care staff", "Essential workers", "Health-care staff", "Care-home residents", "Care-home residents", "Care-home residents", "Care-home residents", "Health-care staff", "Health-care staff", "Health-care staff", "Health-care staff", "Essential workers", "Essential workers", "Health-care staff", "Care-home residents", "Care-home residents", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Campaign planned", "Health-care staff", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available", "Not yet available"]
)
);
graphType = "Map",
topoJSON = "https://www.canvasxpress.org/data/maps/EUROPE.json",
mapId = "europeGroups",
theme = "minimal",
colorBy = "Group",
colorScheme = "User",
colors = ["#cc6677", "#332288", "#44aa99", "#ddcc77", "#dddddd"],
legendOrder = Dict(
"Group" => ["Care-home residents", "Essential workers", "Health-care staff", "Campaign planned", "Not yet available"]
),
legendPosition = "topRight",
legendInside = true,
title = "Who gets the first dose?",
subtitle = "Invented priority groups by country",
source = "Synthetic data for illustration"
)


























