All Projects → johnwalley → D3 Tube Map

johnwalley / D3 Tube Map

Licence: bsd-3-clause
Draw tube maps in the style of the London Underground using d3

Labels

Projects that are alternatives of or similar to D3 Tube Map

Britecharts
Client-side reusable Charting Library based on D3.js v5 that allows easy and intuitive use of charts and components that can be composed together creating amazing visualizations.
Stars: ✭ 3,688 (+3379.25%)
Mutual labels:  svg, d3
Rickshaw
JavaScript toolkit for creating interactive real-time graphs
Stars: ✭ 6,506 (+6037.74%)
Mutual labels:  svg, d3
Ngx Charts
📊 Declarative Charting Framework for Angular
Stars: ✭ 4,057 (+3727.36%)
Mutual labels:  svg, d3
Floweaver
View flow data as Sankey diagrams
Stars: ✭ 266 (+150.94%)
Mutual labels:  svg, d3
D3 Simple Slider
A simple interactive SVG slider
Stars: ✭ 64 (-39.62%)
Mutual labels:  svg, d3
React Native Svg Charts Examples
A collection of usage examples of react-native-svg-charts
Stars: ✭ 266 (+150.94%)
Mutual labels:  svg, d3
React D3 Tree
🌳 React component to create interactive D3 tree graphs
Stars: ✭ 543 (+412.26%)
Mutual labels:  svg, d3
Vue Tree Chart
flexible tree chart using Canvas and Svg, powered by D3.js
Stars: ✭ 149 (+40.57%)
Mutual labels:  svg, d3
Vue D3 Workshop
Workshop content material and excercises for Suncoast Developers
Stars: ✭ 63 (-40.57%)
Mutual labels:  svg, d3
Resonance
◾️Resonance | 5kb React animation library
Stars: ✭ 1,011 (+853.77%)
Mutual labels:  svg, d3
Visx
🐯 visx | visualization components
Stars: ✭ 14,544 (+13620.75%)
Mutual labels:  svg, d3
C3
📊 A D3-based reusable chart library
Stars: ✭ 9,163 (+8544.34%)
Mutual labels:  svg, d3
D3tutorial
📊📈 A D3 v6 tutorial - interactive bar chart and multiple coordinated views (MCV)
Stars: ✭ 163 (+53.77%)
Mutual labels:  svg, d3
Rumble Charts
React components for building composable and flexible charts
Stars: ✭ 293 (+176.42%)
Mutual labels:  svg, d3
React Native Svg Charts
📈 One library to rule all charts for React Native 📊
Stars: ✭ 2,056 (+1839.62%)
Mutual labels:  svg, d3
Billboard.js
📊 Re-usable, easy interface JavaScript chart library based on D3.js
Stars: ✭ 5,032 (+4647.17%)
Mutual labels:  svg, d3
Earthjs
D3 Earth JS
Stars: ✭ 128 (+20.75%)
Mutual labels:  svg, d3
Nn Svg
Publication-ready NN-architecture schematics.
Stars: ✭ 805 (+659.43%)
Mutual labels:  svg, d3
D3
This is the repository for my course, Learning Data Visualization with D3.js on LinkedIn Learning and Lynda.com.
Stars: ✭ 64 (-39.62%)
Mutual labels:  svg, d3
Vega
A visualization grammar.
Stars: ✭ 9,554 (+8913.21%)
Mutual labels:  svg, d3

d3-tube-map

Build Status

Draw tube maps in the style of the London Underground using d3.

See a demo on bl.ocks.org or Observable.

Screenshot

A word of warning. This was created to scratch my own itch (Cambridge Pub Map). It works, but can be difficult to work with. That said, here are examples of other people creating awesome visualizations:

Installing

If you use NPM, npm install d3-tube-map. Otherwise, download the latest release. AMD, CommonJS, and vanilla environments are supported. In vanilla, a d3 global is exported:

<script src="https://d3js.org/d3.v6.js"></script>
<script src="../dist/d3-tube-map.js"></script>

<script>
  var container = d3.select("#tube-map");

  var width = 1600;
  var height = 1024;

  var map = d3
    .tubeMap()
    .width(width)
    .height(height)
    .margin({
      top: height / 50,
      right: width / 7,
      bottom: height / 10,
      left: width / 7,
    });

  d3.json("./pubs.json").then(function (data) {
    container.datum(data).call(map);
  });
</script>

API Reference

# d3.tubeMap() <>

Constructs a new tube map generator with the default settings.

# tubeMap(selection) <>

Render the tube map to the given selection, which is a selection.

# tubeMap.width(w) <>

Sets the width of the viewbox the map is rendered to.

# tubeMap.height(h) <>

Sets the height of the viewbox the map is rendered to.

# tubeMap.margin(m) <>

Sets the margin around the map. Takes an object of the following form:

{ top: 10, right: 20, bottom: 10, left: 20 }

Input Data Format

The data passed to the tube map should have the following properties: stations, lines and optionally river. A minimal example is shown below.

{
  "stations": {
    "StationA": {
      "label": "Station A"
    },
    "StationB": {
      "label": "Station B"
    }
  },
  "lines": [
    {
      "name": "LineA",
      "color": "#FF0000",
      "shiftCoords": [0, 0],
      "nodes": [
        {
          "coords": [23, -4],
          "name": "StationA",
          "labelPos": "N"
        },
        {
          "coords": [30, -4]
        },
        {
          "coords": [31, -3],
        },
        {
          "coords": [31, 2],
          "name": "StationB",
          "labelPos": "E"
        }
      ]
    }
  ]
}

stations is an object where each property is a a station with the key being a unique identifier and the value being an object with a label property. The label is the display friendly text that will be rendered to the screen.

lines is an array of line objects. Each line must have the following:

  • name will be used as the id of the svg path element
  • color is simply the color of the line
  • shiftCoords will translate the whole line in the x and y directions
  • nodes is an array of nodes which define the layout of the line

A line may optionally also define:

  • shiftNormal will offset the line along the direction of its normal vector

Each node must have the following:

  • coords is the position of the node. Must be integer values
  • name should be present if the node represents a station. It should match a station defined in the top-level stations property
  • labelPos should be present if the node represents a station. It is a compass direction and determines where the label is positioned relative to the node, e.g. NE would place the label up and to the right of the node

Corners

Two types of corner are supported: a 90 degree turn and a 45 degree turn. The latter is recognised when the position of a node differs from the position of the previous node by either:

  • 1 in the x direction and 2 in the y direction
  • 2 in the x direction and 1 in the y direction

For example:

[
  {
    "coords": [-27, -11]
  },
  {
    "coords": [-26, -9]
  }
]

A 90 degree turn is recognised when the position of a node differs from the position of the previous node by:

  • 1 in the x direction and 1 in the y direction

For example:

[
  {
    "coords": [0, 2]
  },
  {
    "coords": [1, 1],
  }
]
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].