(This chart is a part of the d3-charts
collection available here.)
This chart provides a historical view of the---at times---shifting majorities of the two parliamentary coalitions in the polls. Due to the dull nation of Danish politics, the majority has been very one-sided this term.
Compare this to Sam Wang's chart for the U.S. 2012 election.
The chart currently uses a LOESS regression to create a trend line---partly to alleviate the noise from a heavy dataset with a lot of polls and pollsters.
NB: Be aware that this chart does not currently take vote thresholds into account; if a party falls below it, its vote share will still be added to its coalition tally. Most, if not all, parliamentary coalition-majority charts do not account for this, but that is no excuse creating the impression of a non-existent parliamentary majority.
All parameters are in the top of the script under // Config
. If we use the example script:
var dataset = "https://data.ndarville.com/danish-polls/data.csv", // "data.csv"
parseDate = d3.time.format("%Y-%m-%d").parse,
dateValue = "Date",
lastElectionDate = "2011-09-15", // ""
nextElectionDate = "2015-09-14", // ""
coalitionLeft = ["A", "B", "F", "Ø", "Å"],
coalitionLeftColor = "#2B83BA", // accessible red
coalitionRight = ["V", "O", "K", "I", "C"],
coalitionRightColor = "#D7191C", // accessible blue
yAxisTitle = "Votes (50%)",
loessRegression = true, // false
loessBandwidth = .1; // .2
// On a smaller dataset, you may want a bandwidth of .2
parseDate
refers to the date format---in this case YYYY-MM-DD
.
lastElectionDate
and nextElectionDate
refer to the date of the past and future election, if known. This will change the minimum and maximum on the x-axis to said date to contextualize the trends.
coalitionLeft/coalitionRight
refer to the letters of each member party of a coalition, entered as strings in an array.
loessRegression
and loessBandwidth
should just be left as-is, unless you're a total statistical-regression dork.
You can experiment with changing loessBandwidth
to .2
for a smoother trend.
The other parameters should be self-explanatory.
Modified http://d3js.org/d3.v3.min.js to a secure url
https://d3js.org/d3.v3.min.js