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.
Installation
npm install --save parliament-svgUsage
const parliamentSVG = require('parliament-svg')
const svg = parliamentSVG(parties, seatCount)partiesis 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.
seatCountis a boolean, iftruethe total seat count will be displayed in the chart
For the given parties object and seatCount enabled, the rendered result should look like this:
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
- westminster-svg - "westminster-style parliament charts"
- d3-parliament - "parliament charts for D3"
- wikidata-parliament-svg - "draws parliament graphs based on data from wikidata"
Contributing
If you found a bug or want to propose a feature, feel free to visit the issues page.