Drawing a background map is the first step of any geospatial analysis. Once this background is available, you can color each region to get a choropleth map, add points or bubble to get a bubble map, reshape the region to get a cartogram, or show connection with a connection map.
<!-- 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/canvasXpress.min.js"></script> <!-- 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 = { "x" : { "Latitude" : [40.701,40.702,40.703], "Longitude" : [-73.985,-74.011,-73.991], "color" : ["blue","red","green"], "shape" : ["circle","teardrop","star"], "size" : [1,1.5,3] }, "y" : { "smps" : ["New York 1","New York 2","New York 3"] } } <-- Create the configuration for the graph --> var config = { "graphType":"Map", "mapConfig":{ "center":[ 40.7, -74 ], "zoom":15 }, "markerBy":"shape", "showLegend":"false", "useLeaflet":"true" } <!-- Call the CanvasXpress function to create the graph --> var cX = new CanvasXpress("canvasId", data, config); </script>
library(canvasXpress) y=read.table("https://www.canvasxpress.org/data/cX-mapdecor-dat.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE) x=read.table("https://www.canvasxpress.org/data/cX-mapdecor-smp.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE) canvasXpress( data=y, smpAnnot=x, graphType="Map", mapConfig=list(center=list(40.7, -74), zoom=15), markerBy="shape", showLegend=FALSE, useLeaflet=TRUE )