GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - geodesign/spatialsankey: D3 Plugin for visualizing flows on a leaflet map

BranchesTags
Open more actions menu

Latest commit

 

History

26 Commits
26 Commits

Folders and files

NameName
Last commit message
Last commit date
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
bower.json
bower.json
 
 
spatialsankey.js
spatialsankey.js
 
 

Repository files navigation

Sankey diagrams on a map

D3 Plugin for visualizing flows through a network on a leaflet map.

Here is a small example application of the plugin.

The spatialsankey plugin is inspired by the d3-plugin sankey and the the example integration of D3 elements into a leaflet map follows the D3 + Leaflet tutorial.

To use it, prepare a set of points as geojson and an array of link values as either csv or json. The links are defined as an array of objects with a source, target and flow value. The source and targets are the point IDs from the geojson points. Example data snippets are shown below.

After loading the data, the links can be displayed on a leaflet map with just a few lines of code:

// Instantiate spatial sankey
var spatialsankey = d3.spatialsankey()
                      .lmap(map)
                      .nodes(nodes.features)
                      .links(links);

// Draw nodes
var node = spatialsankey.node();
var circs = nodelayer.selectAll("circle")
                     .data(spatialsankey.nodes())
                     .enter()
                     .append("circle")
                     .attr("cx", node.cx)
                     .attr("cy", node.cy)
                     .attr("r", node.r)
                     .style("fill", node.fill);
                     
// Draw links
link = spatialsankey.link();
var beziers = linklayer.selectAll("path")
                       .data(nodelinks);
                       .enter()
                       .append("path")
                       .attr("d", link)
                       .attr('id', function(d){return d.id})
                       .style("stroke-width", linke.width())
                       .style("fill", 'none');

nodes.geojson

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "id": "AD",
      "geometry": {
        "type": "Point",
        "coordinates": [ 1.6002, 42.5462 ]
      }
    },
    {
      "type": "Feature",
      "id": "AE",
      "geometry": {
        "type": "Point",
        "coordinates": [ 53.9791, 23.4330 ]
      }
    },
    {
      "type": "Feature",
      "id": "AF",
      "geometry": {
        "type": "Point",
        "coordinates": [ 65.5818, 33.6508 ]
      }
    }
]}

links.csv

target,source,flow
AD,AE,23230
AD,AF,371
AF,AE,1310

About

D3 Plugin for visualizing flows on a leaflet map

Resources

Readme
BSD-3-Clause license
Activity
Custom properties

Stars

49 stars

Watchers

3 watching

Forks

15 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.