All examples By author By category About

ndarville

Party Trend (Single-Party Display)

(This chart is a part of the d3-charts collection available here.)


The subject of this project is nowhere near as exciting as its title would suggest. It aims to present a trend for a political party, or candidate, by combining the polling from multiple institutes as well as their confidence interval.

This chart has two basic views:

The single-party display is the main aim of the chart, but there is support for those of you who want to display multiple parties at once, be it all or a selection of your choice to make a poignant comparison.

This visualization shows the polling for the Danish Social Democrats.

An example of an all-party display can be found here.

Compare this to the trend charts for the Danish Social Democrats by Erik Gahner Larsen and M. Schmidt.

The chart employs a LOESS regression to plot a trend. The LOESS function currently has a bandwidth value of .2.

Usage

var dataset = "https://data.ndarville.com/danish-polls/data.csv", // "data.csv"
    parseDate = d3.time.format("%Y/%m/%d").parse,
    dateValue = "Date",
    instituteValue = "Polling Firm",
    lastElectionDate = "2011-09-15", // ""
    nextElectionDate = "2015-09-14", // ""
    periods = [
        {
            "start" : "2015-01-07",
            "end"   : "2015-02-14",
            "color" : "",
            "label" : "Hebdo and CPH"
        }
    ], // `periods = []`
    periodLabels = false, // true
    yAxisTitle = "Votes (%)",
    votingThreshold = 2.0,
    showDots = true,
    showAllParties = false,
    recalculateYMax = false;
    parties = showAllParties === true ? [] : ["A"];

var ignoreFilter = [
    "Lead",
    "Red (A+B+F+Ø)",
    "Blue (V+O+I+C+K)"
]

// Autoconfig
var singleParty = (showAllParties === false && parties.length === 1) ? true : false,
    displayInstitutes = singleParty;