File: wahldaten.html

package info (click to toggle)
jsxgraph 1.3.5+dfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 26,044 kB
  • sloc: xml: 5,869; java: 1,072; python: 747; php: 192; makefile: 146; sh: 47
file content (324 lines) | stat: -rw-r--r-- 13,948 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
<html>
<head> 
   <meta charset="UTF-8"> 
   <title>JSXGraph example</title>
   <link rel="stylesheet" type="text/css" href="../distrib/jsxgraph.css" />
   <script type="text/javascript" src="/javascript/prototype/prototype.js"></script>
   <script type="text/javascript" src="../src/loadjsxgraph.js"></script>
   <script type="text/javascript" src="wahldaten.js"></script>
   <script type="text/javascript" src="germany.js"></script>   
</head>
<body>
<h2>Bundestagswahl 2009</h2>
<div style="width:800px">
  <div id="jxgbox" class="jxgbox" style="width:500px; height:700px; float:left"></div>
  <div id="wahlkreis">&nbsp;</div>
</div>
<form>
    <input type="radio" value="0" onclick="selectParty(0);" name="parties" checked='checked'>CDU/CSU<br/>
    <input type="radio" value="1" onclick="selectParty(1);" name="parties">SPD<br/>
    <input type="radio" value="2" onclick="selectParty(2);" name="parties">FDP<br/>
    <input type="radio" value="3" onclick="selectParty(3);" name="parties">Die Gr&uuml;nen<br/>
    <input type="radio" value="4" onclick="selectParty(4);" name="parties">Die Linke<br/>
    <input type="radio" value="5" onclick="selectParty(5);" name="parties">NPD<br/>
    <input type="radio" value="6" onclick="selectParty(6);" name="parties">REP<br/>
    <input type="radio" value="7" onclick="selectParty(7);" name="parties">DVU<br/>
    <input type="radio" value="8" onclick="selectParty(8);" name="parties">Die Piraten<br/>
    <br />
    <input type="radio" value="9" onclick="selectParty(9);" name="parties">Wahlbeteiligung<br/>
</form>
<br>
<div id="debug" ></div>
   <script type="text/javascript">
    /* <![CDATA[ */
    var minX =-289319.4,
        maxY = 6827620,
        maxX = 351315.7,
        minY = 5960587,
        brd,
        wahlkreisNode = document.getElementById('wahlkreis').firstChild,    
        points = [],
        len = data.length, // from germany.js
        lastWk = null,
        lastWkNr = 0,
        i, col = 0;
    
    var CDUcols = ['#d3e9fe','#8db0fe','#405dff','#002ba5','#001654'];
    var SPDcols = ['#ffceb8','#fe946a','#f83a1f','#bb0000','#7e0900'];
    var FDPcols = ['#f9feae','#fff95e','#fee80c','#fecc12','#ffc400'];
    var GRUENcols = ['#e4de4d','#b5c213','#508229','#508229','#062f00'];
    var LINKScols = ['#fed0f5','#f3a3ff','#cb6cff','#952aea','#640390'];
    var RECHTScols = ['#fee284','#d3a936','#ab6c00','#714702','#492e00'];
    var PIRATENcols = ['#d3d3d3','#a9a9a9','#4a4a4a','#131313','#ff8800'];
    var BETcols = ['#f8fde6','#e4e5b8','#889780','#354f4f','#002a2d'];
    var CDUCSU = new Array(299);
    var SPD = new Array(299);
    var FDP = new Array(299);
    var GRUEN = new Array(299);
    var LINKS = new Array(299);
    var NPD = new Array(299);
    var REP = new Array(299);
    var DVU = new Array(299);
    var PIRATEN = new Array(299);
    var Zweit = new Array(299);
    var Beteiligung = new Array(299);    
    var wkNamen = new Array(299);
    var wkCurves = new Array(300);
    
    for(i=0;i<300;i++) {
        wkCurves[i] = [];
    }
    
    for(var i=5; i<337; i++) {
        if(wahldata[i*135+1] != "") { // keine Leerzeile
            if(wahldata[i*135+3] != "99" && wahldata[i*135+3] != "") { // kein Bundesland, auch nicht Bundesgebiet
                if(wahldata[i*135+3] == "9") {
                    CDUCSU[ wahldata[i*135+1] ] = wahldata[i*135+42]/wahldata[i*135+18]*100; // CSU
                }
                else {
                    CDUCSU[ wahldata[i*135+1] ] = wahldata[i*135+26]/wahldata[i*135+18]*100; // CDU
                }
                
                SPD[ 1*wahldata[i*135+1] ] = (wahldata[i*135+22]/wahldata[i*135+18]*100).toFixed(1);
                FDP[ 1*wahldata[i*135+1] ] = (wahldata[i*135+30]/wahldata[i*135+18]*100).toFixed(1);
                GRUEN[ 1*wahldata[i*135+1] ] = (wahldata[i*135+38]/wahldata[i*135+18]*100).toFixed(1);
                LINKS[ 1*wahldata[i*135+1] ] = (wahldata[i*135+34]/wahldata[i*135+18]*100).toFixed(1);
                NPD[ 1*wahldata[i*135+1] ] = (wahldata[i*135+46]/wahldata[i*135+18]*100).toFixed(1);
                REP [ 1*wahldata[i*135+1] ] = (wahldata[i*135+50]/wahldata[i*135+18]*100).toFixed(1);
                DVU [ 1*wahldata[i*135+1] ] = (wahldata[i*135+102]/wahldata[i*135+18]*100).toFixed(1);
                PIRATEN [ 1*wahldata[i*135+1] ] = (wahldata[i*135+118]/wahldata[i*135+18]*100).toFixed(1);
                Zweit[ 1*wahldata[i*135+1] ] =  wahldata[i*135+18];
                Beteiligung [ 1*wahldata[i*135+1] ] =  (wahldata[i*135+18]/wahldata[i*135+4]*100).toFixed(1);
                wkNamen[ 1*wahldata[i*135+1] ] =  wahldata[i*135+2];
            }
        }
    }    

    function selectParty(i) {
        if(i==0) { // CDU/CSU
            for(var j=1;j<300;j++) {
                for(var k=0; k< wkCurves[j].length; k++) {
                    wkCurves[j][k].setAttribute('fillColor:'+getCSUcolor(j));
                }
            }
        }    
        else if(i==1) { // SPD
            for(var j=1;j<300;j++) {
                for(var k=0; k< wkCurves[j].length; k++) {
                    wkCurves[j][k].setAttribute('fillColor:'+getSPDcolor(j));
                }
            }
        }
        else if(i==2) { // FDP
            for(var j=1;j<300;j++) {
                for(var k=0; k< wkCurves[j].length; k++) {
                    wkCurves[j][k].setAttribute('fillColor:'+getFDPcolor(j));
                }
            }
        }   
        else if(i==3) { // GRUEN
            for(var j=1;j<300;j++) {
                for(var k=0; k< wkCurves[j].length; k++) {
                    wkCurves[j][k].setAttribute('fillColor:'+getGRUENcolor(j));
                }
            }
        }  
        else if(i==4) { // LINKS
            for(var j=1;j<300;j++) {
                for(var k=0; k< wkCurves[j].length; k++) {
                    wkCurves[j][k].setAttribute('fillColor:'+getLINKScolor(j));
                }
            }
        } 
        else if(i==5) { // NPD
            for(var j=1;j<300;j++) {
                for(var k=0; k< wkCurves[j].length; k++) {
                    wkCurves[j][k].setAttribute('fillColor:'+getNPDcolor(j));
                }
            }
        } 
        else if(i==6) { // REP
            for(var j=1;j<300;j++) {
                for(var k=0; k< wkCurves[j].length; k++) {
                    wkCurves[j][k].setAttribute('fillColor:'+getREPcolor(j));
                }
            }
        }
        else if(i==7) { // DVU
            for(var j=1;j<300;j++) {
                for(var k=0; k< wkCurves[j].length; k++) {
                    wkCurves[j][k].setAttribute('fillColor:'+getDVUcolor(j));
                }
            }
        }   
        else if(i==8) { // Piraten
            for(var j=1;j<300;j++) {
                for(var k=0; k< wkCurves[j].length; k++) {
                    wkCurves[j][k].setAttribute('fillColor:'+getPIRATENcolor(j));
                }
            }
        }  
       else if(i==9) { // Wahlbeteiligung
            for(var j=1;j<300;j++) {
                for(var k=0; k< wkCurves[j].length; k++) {
                    wkCurves[j][k].setAttribute('fillColor:'+getBETEILIGUNGcolor(j));
                }
            }
        }          
    }
    
    function getSPDcolor(col) {
        if(SPD[col] < 18) { return SPDcols[0]; }
        else if(SPD[col] >= 18 && SPD[col] < 23) { return SPDcols[1]; }
        else if(SPD[col] >= 23 && SPD[col] < 28) { return SPDcols[2]; }
        else if(SPD[col] >= 28 && SPD[col] < 33) { return SPDcols[3]; }
        else { return SPDcols[4]; }
    }
    
    function getCSUcolor(col) {
        if(CDUCSU[col] < 30) { return CDUcols[0]; }
        else if(CDUCSU[col] >= 30 && CDUCSU[col] < 35) { return CDUcols[1]; }
        else if(CDUCSU[col] >= 35 && CDUCSU[col] < 40) { return CDUcols[2]; }
        else if(CDUCSU[col] >= 40 && CDUCSU[col] < 45) { return CDUcols[3]; }
        else { return CDUcols[4]; }
    }   
    
    function getFDPcolor(col) {
        if(FDP[col] <= 10) { return FDPcols[0]; }
        else if(FDP[col] > 10 && FDP[col] <= 13) { return FDPcols[1]; }
        else if(FDP[col] > 13 && FDP[col] <= 16) { return FDPcols[2]; }
        else if(FDP[col] > 16 && FDP[col] <= 19) { return FDPcols[3]; }
        else { return FDPcols[4]; }
    } 
    
    function getGRUENcolor(col) {
        if(GRUEN[col] < 6) { return GRUENcols[0]; }
        else if(GRUEN[col] >= 6 && GRUEN[col] < 10) { return GRUENcols[1]; }
        else if(GRUEN[col] >= 10 && GRUEN[col] < 14) { return GRUENcols[2]; }
        else if(GRUEN[col] >= 14 && GRUEN[col] < 20) { return GRUENcols[3]; }
        else { return GRUENcols[4]; }
    }   

    function getLINKScolor(col) {
        if(LINKS[col] < 12) { return LINKScols[0]; }
        else if(LINKS[col] >= 12 && LINKS[col] < 19) { return LINKScols[1]; }
        else if(LINKS[col] >= 19 && LINKS[col] < 26) { return LINKScols[2]; }
        else if(LINKS[col] >= 26 && LINKS[col] < 33) { return LINKScols[3]; }
        else { return LINKScols[4]; }
    }   
    
    function getNPDcolor(col) {
        if(NPD[col] < 1) { return RECHTScols[0]; }
        else if(NPD[col] >= 1 && NPD[col] < 2) { return RECHTScols[1]; }
        else if(NPD[col] >= 2 && NPD[col] < 3) { return RECHTScols[2]; }
        else if(NPD[col] >= 3 && NPD[col] < 4) { return RECHTScols[3]; }
        else { return RECHTScols[4]; }
    }

    function getREPcolor(col) {
        if(REP[col] <= 0.5) { return RECHTScols[0]; }
        else if(REP[col] >= 0.5 && REP[col] <= 0.75) { return RECHTScols[1]; }
        else if(REP[col] >= 0.75 && REP[col] <= 1) { return RECHTScols[2]; }
        else if(REP[col] >= 1 && REP[col] <= 1.25) { return RECHTScols[3]; }
        else { return RECHTScols[4]; }
    }   

    function getDVUcolor(col) {
        if(DVU[col] < 0.5) { return RECHTScols[0]; }
        else if(DVU[col] >= 0.5 && DVU[col] < 0.75) { return RECHTScols[1]; }
        else if(DVU[col] >= 0.75 && DVU[col] < 1) { return RECHTScols[2]; }
        else if(DVU[col] >= 1 && DVU[col] < 1.25) { return RECHTScols[3]; }
        else { return RECHTScols[4]; }
    }
    
    function getPIRATENcolor(col) {
        if(PIRATEN[col] < 1) { return PIRATENcols[0]; }
        else if(PIRATEN[col] >= 1 && PIRATEN[col] < 1.5) { return PIRATENcols[1]; }
        else if(PIRATEN[col] >= 1.5 && PIRATEN[col] < 2) { return PIRATENcols[2]; }
        else if(PIRATEN[col] >= 2 && PIRATEN[col] < 2.5) { return PIRATENcols[3]; }
        else { return PIRATENcols[4]; }
    }  
    
    function getBETEILIGUNGcolor(col) {
        if(Beteiligung[col] < 66) { return BETcols[0]; }
        else if(Beteiligung[col] >= 66 && Beteiligung[col] < 69) { return BETcols[1]; }
        else if(Beteiligung[col] >= 69 && Beteiligung[col] < 72) { return BETcols[2]; }
        else if(Beteiligung[col] >= 72 && Beteiligung[col] < 75) { return BETcols[3]; }
        else { return BETcols[4]; }
    }      
    
    brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[minX-1000,maxY+1000,maxX+1000,minY-1000],
                                        keepaspectratio:true});

    for(i=0;i<len;i++) {
        if(i%6==1) {
            lastWk = data[i];
        }
        else if(i%6==0) {
            lastWkNr = data[i];
        }        
        else if(i%6 == 5) {
            points.push([data[i],lastWk,lastWkNr]);
        }
    }

    function createCurve(area)  {
        var compos = area[0].split(';'), // Zusammenhangskomponenten
            x = [], y = [],
            c = [], num, i, a, graph, k, a;
            
        num = compos.length;
        for (k=0;k<num;k++) {
            x = []; y = []; c = [];
            xy = compos[k].split(',');            
            len = xy.length;
            for(i=0;i<len;i++) {
                a = xy[i].split(' ');
                c.push(new JXG.Coords(JXG.COORDS_BY_USER, [1*a[0], 1*a[1]], brd));
            }
            c = JXG.Math.Numerics.RamerDouglasPeucker(c,1.2);
            len = c.length;
            for (i=0;i<len;i++) {
                x.push(c[i].usrCoords[1]);
                y.push(c[i].usrCoords[2]);
            }
            graph = brd.create('curve', [x,y], 
                        {fillColor:getCSUcolor(area[2]),
                         highlightFillColor:'yellow',
                         strokeWidth:1,strokeColor:'black',highlightStrokeColor:'black'});
            wkCurves[ [area[2]] ].push(graph);
            if(k==0) {                 
                JXG.addEvent(graph.rendNode, 'mouseover', (function(g){ return function(){g.highlight(); /*wahlkreisNode.nodeValue=Beteiligung[area[2] ]+" "+area[2];*/};})(graph), graph);
                JXG.addEvent(graph.rendNode, 'mouseout', (function(g){ return function(){g.noHighlight();};})(graph), graph);
            }
            graph.hasPoint = function(){return false; };
        }
    }

    function final() {
        brd.unsuspendUpdate();
    }

    //Copyright 2009 Nicholas C. Zakas. All rights reserved.
    //MIT Licensed
    function timedChunk(items, process, context, callback){
        var todo = items.concat();   //create a clone of the original
        setTimeout(function(){
            var start = +new Date();
            do {
                process.call(context, todo.shift());
            } while (todo.length > 0 && (+new Date() - start < 300));
            if (todo.length > 0){
                setTimeout(arguments.callee, 1);
            } else {
                callback(items);
            }
        }, 1);
    }

    brd.suspendUpdate();
    timedChunk(points, createCurve, null, final);
          /* ]]> */
  </script>
</body>
</html>