Code Monkey home page Code Monkey logo

tube-map's Introduction

Tube Map

This was created to meet a need of drawing data driven process diagrams. I wanted to use Harry Beck's classic London Underground map as an inspiration for the layout.

I attempted to follow as much of the TFL line diagram standards as possible: https://content.tfl.gov.uk/tfl-line-diagram-standard.pdf

Example

Example process

This example is included in the code. You can see it straight away by pulling down the repo and then running

npm ci
npm start

It should open in your browser, and if not, visit http://localhost:3000

How to use

The tool is designed to draw diagrams from left to right only, and it expects a single starting point.

The tool expects a data structure containing two items, the branches of the process and the milestones. Each should be an object.

const data = {
  branches: {},
  milestones: {}
}

Branches

The branches object should contain one or more objects, each of which defines a a process branch. For example

const data = {
  branches: {
    brancha: {},
    branchb: {}
  }
}

Each branch should be defined as follows:

{
  name: "Name of the branch",
  seq: "",
  colour: ""
}
Property Purpose
name Name of the branch, which is displayed on the diagram
seq The sequence of lines and milestones
colour What colour should the process branch, can be a hex colour e.g. #ff0000 or a standard colour name e.g. red

seq should be a comma-separated string containing the instructions to draw the process branch. Each comma-separated substring should conform to the following scheme:

Substring Purpose
- Draw a straight line
/ Draw an upward branch
\ Draw a downward branch
$ End the process
string Draw a milestone with details defined in milestone object under key string

Milestones

Each of the milestones referenced in the sequences should be defined in the milestones object. Each milestone should have a name and optionally a colour as follows:

const data = {
  branches: {},
  milestones: {
    milestone1: {
      name: "Start of the process",
      colour: "red"
    }
  }
}

The colour attribute is optional and if not present the default colour is white

Including it in your app

After defining your data object, including the tube-map is quite easy:

import Map from './Map';

// in your render method:
return (
  <Map 
    data={data}
    debug={false}
    dimensions={{
      width: 1000, height: 400,
      margin: { top: 0, right: 30, bottom: 30, left: 0 }
    }}
  />
)

Setting debug to true is useful if you want to see how the drawing is done or work out the source of problems. It will draw some helpers and a grid.

Still to-do

  • Support for clicking milestones
  • Support for 'tool-tip' style mouse overs on milestones

Acknowledgements

This project was bootstrapped with Create React App.

tube-map's People

Contributors

richardjkendall avatar

Stargazers

Tharaka Romesh avatar Dave avatar Rob avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.