/* Add spinner */ var opts = { lines : 13, // The number of lines to draw length : 20, // The length of each line width : 10, // The line thickness radius : 30, // The radius of the inner circle corners : 1, // Corner roundness (0..1) rotate : 0, // The rotation offset direction : 1, // 1: clockwise, -1: counterclockwise color : '#000', // #rgb or #rrggbb or array of colors speed : 1, // Rounds per second trail : 60, // Afterglow percentage shadow : false, // Whether to render a shadow hwaccel : false, // Whether to use hardware acceleration className : 'spinner', // The CSS class to assign to the spinner zIndex : 2e9, // The z-index (defaults to 2000000000) top : '40%', // Top position relative to parent left : '50%' // Left position relative to parent }; var data_long var data_long_seats; var data_polls; var data_diff; var data_winlose; /* TRENDS GRAPH */ show_graph_long = function () { if (typeof g == 'undefined') { var target = document.getElementById('pw'); var spinner = new Spinner(opts).spin(target); /* Load data long*/ $.ajax({ url:url_base + 'Results_DyGraphs.csv', dataType: 'text', cache: true, success: function(data) { data_long = data; init_graph_long(); } }) /* Load data long seats*/ $.ajax({ url:url_base + 'Results_DyGraphs_Seats.csv', dataType: 'text', cache: true, success: function(data) { data_long_seats = data; } }) } else { g.resize(); }; }; init_graph_long = function () { g = new Dygraph( document.getElementById('pw'), data_long, { customBars : true, ylabel : text_schatting, labelsDiv : 'pwlabels', legend : 'always', labelsDivStyles : { 'textAlign' : 'right' }, colors : ['#455493', '#9a0d1b', '#00B9FF', '#c73d77', '#00894b', '#4aab2d', '#0094b4', '#006b39', '#7f8084', '#EBC30A', '#c2791e', '#124892', '#41BAC1','#6e0c13', '#572B85'], showRangeSelector : true, rangeSelectorHeight: 10, rangeSelectorPlotFillColor: 'white', rangeSelectorPlotStrokeColor: '', highlightSeriesBackgroundAlpha : 0.2, axes : { x : { valueFormatter : function (millis, opts) { lastRow = null; lastCol = 0; for (var i = 0; i < g.numRows(); i++) { if (g.getValue(i, 0) == millis) { lastRow = i; break; } } // forward to the default formatter. return Dygraph.dateValueFormatter.apply(this, arguments); } }, y : { valueFormatter : function (num, opts) { lastCol++; // Find out what the real column is, as invisible columns are not called upon for the valueFormatter and might thus receive the wrong data var visibleColumn = 0; for (var realColumn = 1; realColumn < g.numColumns(); realColumn++) { if (g.visibility()[realColumn - 1] == true) { visibleColumn++; }; if (visibleColumn == lastCol) { break; } } var threevalues = g.getValue(lastRow, realColumn).toString(); var low = parseFloat(threevalues.split(",")[0]).toFixed(g_round_prec); var hi = parseFloat(threevalues.split(",")[2]).toFixed(g_round_prec); return "" + num.toFixed(g_round_prec) + " (" + low + " - " + hi + ")"; } } }, highlightSeriesOpts : { strokeWidth : 3, strokeBorderWidth : 1, highlightCircleSize : 5, } }); /* Zoom to last year */ var minDate = g.xAxisRange()[0]; var maxDate = g.xAxisRange()[1]; var start = maxDate - 31556952000; g.updateOptions({ dateWindow: [start, maxDate] }); } /* Functions for long graph */ function change(el, graph) { var id = el.id.split("_")[1] graph.setVisibility(parseInt(id), el.checked); }; function pw_alloff() { for (var i = 0; i < (g.numColumns() - 1); i++) { g.setVisibility(parseInt(i), false); document.getElementById("pw_" + i.toString()).checked = false; } } function pw_allon() { for (var i = 0; i < (g.numColumns() - 1); i++) { g.setVisibility(parseInt(i), true); document.getElementById("pw_" + i.toString()).checked = true; } } function pw_switchtoperc() { if(datasource==1) { g.updateOptions({ ylabel : text_schatting, file : data_long, }); }; if(datasource==2) { g.updateOptions({ ylabel : text_schatting, file : data_long_moa, }); }; window.percentages = 1; g_round_prec = 1; }; function pw_switchtozetel() { if(datasource==1) { g.updateOptions({ ylabel : text_schatting_zetels, file : data_long_seats, }); }; if(datasource==2) { g.updateOptions({ ylabel : text_schatting_zetels, file : data_long_seats_moa, }); } window.percentages = 0; g_round_prec = 0; }; /* POLLS GRAPH */ show_graph_polls = function () { if (typeof g2 == 'undefined') { var target = document.getElementById('pw2'); var spinner = new Spinner(opts).spin(target); $.ajax({ url:url_base + 'Results_DyGraphs_Polls.csv', dataType: 'text', cache: true, success: function(data) { data_polls = data; init_graph_polls(); } }) } else { g2.resize(); }; }; init_graph_polls = function () { g2 = new Dygraph( document.getElementById('pw2'), data_polls, { customBars : true, ylabel : text_schatting, labelsDiv : 'pw2labels', legend : 'always', labelsDivStyles : { 'textAlign' : 'right' }, colors : ['#455493', '#00008B', '#8B0000', '#006400', '#FFA500', '#99B7A7', '#26676D', '#9a0d1b', '#00008B', '#8B0000', '#006400', '#FFA500', '#99B7A7', '#26676D', '#00B9FF', '#00008B', '#8B0000', '#006400', '#FFA500', '#99B7A7', '#26676D', '#c73d77', '#00008B', '#8B0000', '#006400', '#FFA500', '#99B7A7', '#26676D', '#00894b', '#00008B', '#8B0000', '#006400', '#FFA500', '#99B7A7', '#26676D', '#4aab2d', '#00008B', '#8B0000', '#006400', '#FFA500', '#99B7A7', '#26676D', '#0094b4', '#00008B', '#8B0000', '#006400', '#FFA500', '#99B7A7', '#26676D', '#006b39', '#00008B', '#8B0000', '#006400', '#FFA500', '#99B7A7', '#26676D', '#7f8084', '#00008B', '#8B0000', '#006400', '#FFA500', '#99B7A7', '#26676D', '#EBC30A', '#00008B', '#8B0000', '#006400', '#FFA500', '#99B7A7', '#26676D', '#c2791e', '#00008B', '#8B0000', '#006400', '#FFA500', '#99B7A7', '#26676D', '#124892', '#00008B', '#8B0000', '#006400', '#FFA500', '#99B7A7', '#26676D', '#41BAC1', '#00008B', '#8B0000', '#006400', '#FFA500', '#99B7A7', '#26676D', '#6e0c13', '#00008B', '#8B0000', '#006400', '#FFA500', '#99B7A7', '#26676D', '#572B85', '#00008B', '#8B0000', '#006400', '#FFA500', '#99B7A7', '#26676D'], visibility : [true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false], showRangeSelector : true, rangeSelectorHeight: 10, rangeSelectorPlotFillColor: 'white', rangeSelectorPlotStrokeColor: '', connectSeparatedPoints: false, highlightSeriesOpts : { strokeWidth : 3, strokeBorderWidth : 1, highlightCircleSize : 5, connectSeparatedPoints : false, }, pointSize : 3, axes : { y : { valueFormatter : function (y) { return y.toFixed(1); }, } }, }); /* Zoom to last year */ var minDate = g2.xAxisRange()[0]; var maxDate = g2.xAxisRange()[1]; var start = maxDate - 31556952000; g2.updateOptions({ dateWindow: [start, maxDate] }); }; var current_vis_party = 'vvd'; var current_vis = 0; function graph_poll_change(party) { parties = ['vvd','pvda','pvv','sp','cda','d66','cu','gl','sgp','pvdd','50plus','vnl','denk','fvd','pp']; var party_num = parties.indexOf(party) * 7; if(datasource==2) party_num = parties.indexOf(party) * 6; g2.setVisibility(current_vis, false); g2.setVisibility(current_vis + 1, false); g2.setVisibility(current_vis + 2, false); g2.setVisibility(current_vis + 3, false); g2.setVisibility(current_vis + 4, false); g2.setVisibility(current_vis + 5, false); if(datasource==1) g2.setVisibility(current_vis + 6, false); g2.setVisibility(party_num, true); g2.setVisibility(party_num + 1, true); g2.setVisibility(party_num + 2, true); g2.setVisibility(party_num + 3, true); g2.setVisibility(party_num + 4, true); g2.setVisibility(party_num + 5, true); if(datasource==1) g2.setVisibility(party_num + 6, true); current_vis=party_num; current_vis_party = party; } /* DIFFERENCE GRAPH */ show_graph_diff = function () { if (typeof g3 == 'undefined') { var target = document.getElementById('pw3'); var spinner = new Spinner(opts).spin(target); $.ajax({ url:url_base + 'Results_DyGraphs_Diff.csv', dataType: 'text', cache: true, success: function(data) { data_diff = data; init_graph_diff(); } }) } else { g3.resize(); }; }; init_graph_diff = function () { g3 = new Dygraph( document.getElementById('pw3'), data_diff, { customBars : true, ylabel : text_schatting_verschil, labelsDiv : 'pw3labels', legend : 'always', labelsDivStyles : { 'textAlign' : 'right' }, visibility : [false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false], showRangeSelector : true, rangeSelectorHeight: 10, rangeSelectorPlotFillColor: 'white', rangeSelectorPlotStrokeColor: '', drawAxesAtZero : true, axes : { y : { valueFormatter : function (y) { return y.toFixed(1); }, } }, }); /* Zoom to last year */ var minDate = g3.xAxisRange()[0]; var maxDate = g3.xAxisRange()[1]; var start = maxDate - 31556952000; g3.updateOptions({ dateWindow: [start, maxDate] }); }; var current_party1 = 0; var current_party2 = 1; function get_Series(x, y) { var u = x * 15 + y; return (u); }; function change_party1(el) { g3.setVisibility(get_Series(current_party1, current_party2), false); current_party1 = parseInt(el.id); g3.setVisibility(get_Series(current_party1, current_party2), true); }; function change_party2(el) { g3.setVisibility(get_Series(current_party1, current_party2), false); current_party2 = parseInt(el.id); g3.setVisibility(get_Series(current_party1, current_party2), true); }; /* WIN/LOSE GRAPH */ show_graph_winlose = function () { if (typeof g4 == 'undefined') { var target = document.getElementById('pw4'); var spinner = new Spinner(opts).spin(target); $.ajax({ url:url_base + 'Results_DyGraphs_WinLoose.csv', dataType: 'text', cache: true, success: function(data) { data_winlose = data; init_graph_winlose(); } }) } else { g4.resize(); }; }; init_graph_winlose = function () { g4 = new Dygraph( document.getElementById('pw4'), data_winlose, { customBars : true, ylabel : text_schatting_winlose, labelsDiv : 'pw4labels', legend : 'always', labelsDivStyles : { 'textAlign' : 'right' }, colors : ['#455493', '#9a0d1b', '#00B9FF', '#c73d77', '#00894b', '#4aab2d', '#0094b4', '#006b39', '#7f8084', '#EBC30A', '#c2791e', '#124892', '#41BAC1', '#6e0c13', '#572B85'], showRangeSelector : true, rangeSelectorHeight: 10, rangeSelectorPlotFillColor: 'white', rangeSelectorPlotStrokeColor: '', highlightSeriesOpts : { strokeWidth : 3, strokeBorderWidth : 1, highlightCircleSize : 5, }, visibility : [true, false, false, false, false, false, false, false, false, false, false, false, false, false, false], drawAxesAtZero : true, }); /* Zoom to last year */ var minDate = g4.xAxisRange()[0]; var maxDate = g4.xAxisRange()[1]; var start = maxDate - 31556952000; g4.updateOptions({ dateWindow: [start, maxDate] }); }; function change4(el) { g4.setVisibility(parseInt(el.id), el.checked); } // Publication Info $.ajaxSetup({ cache: true }); $.getScript(url_base + 'PublicationInfo.js', function() { document.getElementById('PublicationInfo').innerHTML = '