npm

Need private packages and team management tools?Check out npm Orgs. »

parliament-svg

2.1.4 • Public • Published

parliament-svg

Generate parliament charts as virtual-dom SVG. Design inspired by the Wikipedia parliament charts. Play around with the live demo! For westminster-style parliament charts, see westminster-svg. If you are using D3, you might prefer working with the d3-parliament module.

npm version Build Status Greenkeeper badge dependency status license chat on gitter

Installation

npm install --save parliament-svg

Usage

const parliamentSVG = require('parliament-svg')
 
const svg = parliamentSVG(parties, seatCount)
  • parties is an object containing seat count and colour for each party
{
    "linke": {
        "seats": 64,
        "colour": "#a08"
    },
    "spd": {
        "seats": 193,
        "colour": "#e02"
    },
    "gruene": {
        "seats": 63,
        "colour": "#0b2"
    },
    "union": {
        "seats": 311,
        "colour": "#333"
    }
}

Each seat contains the party name in its class attribute.

  • seatCount is a boolean, if true the total seat count will be displayed in the chart

For the given parties object and seatCount enabled, the rendered result should look like this:

Example: German Bundestag with seat count enabled

If you want to convert the virtual DOM tree to HTML/SVG string, use virtual-dom-stringify:

const toStr = require('virtual-dom-stringify')
const svg = toStr(svg)

See also

Contributing

If you found a bug or want to propose a feature, feel free to visit the issues page.

install

npm i parliament-svg

Downloadsweekly downloads

208

version

2.1.4

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability