Skip to content
master
Switch branches/tags
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

About

Generate parliament charts as virtual-dom SVG

Topics

Resources

License

Releases

No releases published

Packages

No packages published