Last active
August 29, 2015 14:06
-
-
Save michalskop/bb6848e7d705a8e6128b to your computer and use it in GitHub Desktop.
CZ: Senate, towards elections 2014
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import json | |
lastgroup = '' | |
data = [] | |
i = 0 | |
dReader = csv.reader(open('data.csv'),delimiter=",") | |
for row in dReader: | |
if row[5].strip() != lastgroup: | |
if i != 0: | |
data.append(group) | |
lastgroup = row[5].strip() | |
group = { | |
"abbreviation": row[5].strip(), | |
"name": row[7].strip(), | |
"color": row[6].strip(), | |
"people": [] | |
} | |
if int(row[4]) == 0: | |
op = "red" | |
else: | |
op = "green" | |
person = { | |
"name": row[2].strip() + " - " + row[1].strip() + "<br/>" +row[7].strip(), | |
"opacity": 1, | |
"background": op | |
} | |
group['people'].append(person) | |
i = i + 1 | |
data.append(group) | |
with open('hemicycle.json', 'w') as outfile: | |
json.dump(data, outfile) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d3.hemicycle = function() { | |
function hemicycle(selection) { | |
selection.each(function(d, i) { | |
// options | |
var nvar = (typeof(n) === "function" ? n(d) : n), | |
gapvar = (typeof(gap) === "function" ? gap(d) : gap), | |
widthIconvar = (typeof(widthIcon) === "function" ? widthIcon(d) : widthIcon), | |
widthvar = (typeof(width) === "function" ? width(d) : width); | |
groupsvar = (typeof(groups) === "function" ? groups(d) : groups); | |
var rmax = 1 + nvar.length *gapvar*widthIconvar; | |
var xScale = d3.scale.linear() | |
.domain([-1*rmax, rmax]) | |
.range([0, widthvar]), | |
xxScale = d3.scale.linear() | |
.domain([0, 2*rmax]) | |
.range([0, widthvar]) | |
yScale = d3.scale.linear() | |
.domain([0, rmax]) | |
.range([widthvar/2,0]); | |
var data = [], | |
s = []; | |
for (i in nvar) { | |
s.push((Math.PI/widthIconvar + Math.PI*i*gapvar-nvar[i])/(nvar[i] - 1)); | |
var ninrow = nvar[i], | |
radwidth = Math.PI/(nvar[i]+(nvar[i]-1)*s[i]), | |
radspace = radwidth*s[i], | |
r = 1 + i*gapvar*widthIconvar; | |
for (j=0;j<ninrow;j++) { | |
var x = Math.cos(radwidth*(0.5+j)+j*radspace)*r, | |
y = Math.sin(radwidth*(0.5+j)+j*radspace)*r, | |
rot = -1*(radwidth*(0.5+j)+j*radspace)/Math.PI*180+90; | |
data.push({'x':x,'y':y,'rot':rot}); | |
} | |
} | |
data.sort(function(x,y) { | |
if (x['rot'] < y['rot']) return -1; | |
if (x['rot'] > y['rot']) return 1; | |
return 0 | |
}); | |
var i = 0; | |
for (gkey in groupsvar) { | |
var group = groupsvar[gkey]; | |
//for (j=0;j<group['n'];j++) { | |
for (key in group['people']) { | |
person = group['people'][key]; | |
for (var attrname in person) { data[i][attrname] = person[attrname]; } | |
data[i]['color'] = group['color']; | |
//data[i]['name'] = //group['name']; | |
data[i]['widthIcon'] = widthIconvar; | |
i++; | |
} | |
} | |
/*var angle = [{'startangle':0,'endangle':Math.PI/2}]; | |
var arci = d3.svg.arc() | |
.startAngle(function(d){return d.startangle}) | |
.endAngle(function(d){return d.endangle}) | |
.outerRadius(x0Scale(rmax)) | |
.innerRadius(0); | |
var position = [xScale(0),yScale(0)];*/ | |
var element = d3.select(this); | |
var icons = element.selectAll(".icon") | |
.data(data) | |
.enter().append("a") | |
.attr("transform",function(d) {return "rotate("+d.rot+","+xScale(d.x)+","+yScale(d.y)+")"}) | |
.attr("xlink:href",function(d) {return d.link}) | |
.on("mouseover", tip.show) | |
.on("mouseout", tip.hide) | |
; | |
//http://stackoverflow.com/questions/13203897/d3-nested-appends-and-data-flow | |
icons.append("text") | |
.attr('font-size',xxScale( | |
d.widthIcon*1.15/2)) | |
.attr('font-family', 'FontAwesome') | |
.attr('x',function(d) {return xScale(d.x+d.widthIcon/2.8);}) | |
.attr('y',function(d) {return yScale(d.y+d.widthIcon/2.8);}) | |
.attr('fill',function(d) {return d.background}) | |
.attr('text-anchor',"middle") | |
//.text('\uf005'); | |
.text(function(d) {if (d.background == 'red') return '\uf0e7'; else return '\uf0a3';}); | |
icons.append("text") | |
.attr('font-family', 'FontAwesome') | |
.attr('font-size',xxScale( | |
d.widthIcon*1.15)) //the icon is about 1.15times higher then wide | |
.attr('fill', function(d) { | |
return d.color; | |
}) | |
.attr('fill-opacity', function(d) {return d.opacity;}) | |
.attr('stroke-width', function(d) {return 1;}) | |
.attr('stroke-opacity',0.9) | |
.attr('text-anchor',"middle") | |
.attr('class', 'shadow') | |
.attr('x',function(d) {return xScale(d.x);}) | |
.attr('y',function(d) {return yScale(d.y);}) | |
.text('\uf007'); | |
}); | |
} | |
hemicycle.n = function(value) { | |
if (!arguments.length) return value; | |
n = value; | |
return hemicycle; | |
}; | |
hemicycle.gap = function(value) { | |
if (!arguments.length) return value; | |
gap = value; | |
return hemicycle; | |
}; | |
hemicycle.widthIcon = function(value) { | |
if (!arguments.length) return value; | |
widthIcon = value; | |
return hemicycle; | |
}; | |
hemicycle.width = function(value) { | |
if (!arguments.length) return value; | |
width = value; | |
return hemicycle; | |
}; | |
hemicycle.groups = function(value) { | |
if (!arguments.length) return value; | |
groups = value; | |
return hemicycle; | |
}; | |
return hemicycle; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// d3.tip | |
// Copyright (c) 2013 Justin Palmer | |
// | |
// Tooltips for d3.js SVG visualizations | |
(function (root, factory) { | |
if (typeof define === 'function' && define.amd) { | |
// AMD. Register as an anonymous module with d3 as a dependency. | |
define(['d3'], factory) | |
} else { | |
// Browser global. | |
root.d3.tip = factory(root.d3) | |
} | |
}(this, function (d3) { | |
// Public - contructs a new tooltip | |
// | |
// Returns a tip | |
return function() { | |
var direction = d3_tip_direction, | |
offset = d3_tip_offset, | |
html = d3_tip_html, | |
node = initNode(), | |
svg = null, | |
point = null, | |
target = null | |
function tip(vis) { | |
svg = getSVGNode(vis) | |
point = svg.createSVGPoint() | |
document.body.appendChild(node) | |
} | |
// Public - show the tooltip on the screen | |
// | |
// Returns a tip | |
tip.show = function() { | |
var args = Array.prototype.slice.call(arguments) | |
if(args[args.length - 1] instanceof SVGElement) target = args.pop() | |
var content = html.apply(this, args), | |
poffset = offset.apply(this, args), | |
dir = direction.apply(this, args), | |
nodel = d3.select(node), | |
i = directions.length, | |
coords, | |
scrollTop = document.documentElement.scrollTop || document.body.scrollTop, | |
scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft | |
nodel.html(content) | |
.style({ opacity: 1, 'pointer-events': 'all' }) | |
while(i--) nodel.classed(directions[i], false) | |
coords = direction_callbacks.get(dir).apply(this) | |
nodel.classed(dir, true).style({ | |
top: (coords.top + poffset[0]) + scrollTop + 'px', | |
left: (coords.left + poffset[1]) + scrollLeft + 'px' | |
}) | |
return tip | |
} | |
// Public - hide the tooltip | |
// | |
// Returns a tip | |
tip.hide = function() { | |
nodel = d3.select(node) | |
nodel.style({ opacity: 0, 'pointer-events': 'none' }) | |
return tip | |
} | |
// Public: Proxy attr calls to the d3 tip container. Sets or gets attribute value. | |
// | |
// n - name of the attribute | |
// v - value of the attribute | |
// | |
// Returns tip or attribute value | |
tip.attr = function(n, v) { | |
if (arguments.length < 2 && typeof n === 'string') { | |
return d3.select(node).attr(n) | |
} else { | |
var args = Array.prototype.slice.call(arguments) | |
d3.selection.prototype.attr.apply(d3.select(node), args) | |
} | |
return tip | |
} | |
// Public: Proxy style calls to the d3 tip container. Sets or gets a style value. | |
// | |
// n - name of the property | |
// v - value of the property | |
// | |
// Returns tip or style property value | |
tip.style = function(n, v) { | |
if (arguments.length < 2 && typeof n === 'string') { | |
return d3.select(node).style(n) | |
} else { | |
var args = Array.prototype.slice.call(arguments) | |
d3.selection.prototype.style.apply(d3.select(node), args) | |
} | |
return tip | |
} | |
// Public: Set or get the direction of the tooltip | |
// | |
// v - One of n(north), s(south), e(east), or w(west), nw(northwest), | |
// sw(southwest), ne(northeast) or se(southeast) | |
// | |
// Returns tip or direction | |
tip.direction = function(v) { | |
if (!arguments.length) return direction | |
direction = v == null ? v : d3.functor(v) | |
return tip | |
} | |
// Public: Sets or gets the offset of the tip | |
// | |
// v - Array of [x, y] offset | |
// | |
// Returns offset or | |
tip.offset = function(v) { | |
if (!arguments.length) return offset | |
offset = v == null ? v : d3.functor(v) | |
return tip | |
} | |
// Public: sets or gets the html value of the tooltip | |
// | |
// v - String value of the tip | |
// | |
// Returns html value or tip | |
tip.html = function(v) { | |
if (!arguments.length) return html | |
html = v == null ? v : d3.functor(v) | |
return tip | |
} | |
function d3_tip_direction() { return 'n' } | |
function d3_tip_offset() { return [0, 0] } | |
function d3_tip_html() { return ' ' } | |
var direction_callbacks = d3.map({ | |
n: direction_n, | |
s: direction_s, | |
e: direction_e, | |
w: direction_w, | |
nw: direction_nw, | |
ne: direction_ne, | |
sw: direction_sw, | |
se: direction_se | |
}), | |
directions = direction_callbacks.keys() | |
function direction_n() { | |
var bbox = getScreenBBox() | |
return { | |
top: bbox.n.y - node.offsetHeight, | |
left: bbox.n.x - node.offsetWidth / 2 | |
} | |
} | |
function direction_s() { | |
var bbox = getScreenBBox() | |
return { | |
top: bbox.s.y, | |
left: bbox.s.x - node.offsetWidth / 2 | |
} | |
} | |
function direction_e() { | |
var bbox = getScreenBBox() | |
return { | |
top: bbox.e.y - node.offsetHeight / 2, | |
left: bbox.e.x | |
} | |
} | |
function direction_w() { | |
var bbox = getScreenBBox() | |
return { | |
top: bbox.w.y - node.offsetHeight / 2, | |
left: bbox.w.x - node.offsetWidth | |
} | |
} | |
function direction_nw() { | |
var bbox = getScreenBBox() | |
return { | |
top: bbox.nw.y - node.offsetHeight, | |
left: bbox.nw.x - node.offsetWidth | |
} | |
} | |
function direction_ne() { | |
var bbox = getScreenBBox() | |
return { | |
top: bbox.ne.y - node.offsetHeight, | |
left: bbox.ne.x | |
} | |
} | |
function direction_sw() { | |
var bbox = getScreenBBox() | |
return { | |
top: bbox.sw.y, | |
left: bbox.sw.x - node.offsetWidth | |
} | |
} | |
function direction_se() { | |
var bbox = getScreenBBox() | |
return { | |
top: bbox.se.y, | |
left: bbox.e.x | |
} | |
} | |
function initNode() { | |
var node = d3.select(document.createElement('div')) | |
node.style({ | |
position: 'absolute', | |
top: 0, | |
opacity: 0, | |
'pointer-events': 'none', | |
'box-sizing': 'border-box' | |
}) | |
return node.node() | |
} | |
function getSVGNode(el) { | |
el = el.node() | |
if(el.tagName.toLowerCase() == 'svg') | |
return el | |
return el.ownerSVGElement | |
} | |
// Private - gets the screen coordinates of a shape | |
// | |
// Given a shape on the screen, will return an SVGPoint for the directions | |
// n(north), s(south), e(east), w(west), ne(northeast), se(southeast), nw(northwest), | |
// sw(southwest). | |
// | |
// +-+-+ | |
// | | | |
// + + | |
// | | | |
// +-+-+ | |
// | |
// Returns an Object {n, s, e, w, nw, sw, ne, se} | |
function getScreenBBox() { | |
var targetel = target || d3.event.target, | |
bbox = {}, | |
matrix = targetel.getScreenCTM(), | |
tbbox = targetel.getBBox(), | |
width = tbbox.width, | |
height = tbbox.height, | |
x = tbbox.x, | |
y = tbbox.y | |
point.x = x | |
point.y = y | |
bbox.nw = point.matrixTransform(matrix) | |
point.x += width | |
bbox.ne = point.matrixTransform(matrix) | |
point.y += height | |
bbox.se = point.matrixTransform(matrix) | |
point.x -= width | |
bbox.sw = point.matrixTransform(matrix) | |
point.y -= height / 2 | |
bbox.w = point.matrixTransform(matrix) | |
point.x += width | |
bbox.e = point.matrixTransform(matrix) | |
point.x -= width / 2 | |
point.y -= height / 2 | |
bbox.n = point.matrixTransform(matrix) | |
point.y += height | |
bbox.s = point.matrixTransform(matrix) | |
return bbox | |
} | |
return tip | |
}; | |
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 | Znojmo | Marta Bayerová | KSČM | 0 | KSČM | red | Komunistická strana Čech a Moravy | |
---|---|---|---|---|---|---|---|---|
5 | Chomutov | Václav Homolka | KSČM | 2 | KSČM | red | Komunistická strana Čech a Moravy | |
31 | Ústí nad Labem | Jaroslav Doubrava | S.cz | 1 | S.cz | #ff4444 | Severočeši.cz | |
4 | Most | Alena Dernerová | BEZPP | 1 | nez.-S.cz | #ff6666 | nezařazení (Severočeši.cz) | |
45 | Hradec Králové | Vladimír Dryml | SPO | 0 | nez.-SPO | #fdd7e4 | nezařezení (Strana práv občanů) | |
64 | Bruntál | Jaroslav Palas | nezjištěno | 1 | SPO | pink | Strana práv občanů | |
49 | Blansko | Jozef Regec | BEZPP | 1 | SPO | pink | Strana práv občanů | |
44 | Chrudim | Jan Veleba | BEZPP | 2 | SPO | pink | Strana práv občanů | |
48 | Rychnov nad Kněžnou | Miroslav Antl | BEZPP | 0 | ČSSD | orange | Česká strana sociálně demokratická | |
57 | Vyškov | Ivo Bárek | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | |
9 | Plzeň-město | Jiří Bis | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | |
30 | Kladno | Jiří Dienstbier | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | |
81 | Uherské Hradiště | Hana Doupovcová | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | |
78 | Zlín | Alena Gajdůšková | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | |
72 | Ostrava-město | Petr Guziana | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | |
6 | Louny | Marcel Chládek | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | |
36 | Česká Lípa | Karel Kapoun | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | |
66 | Olomouc | Karel Korytář | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | |
63 | Přerov | Jiří Lajtoch | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | |
3 | Cheb | Miroslav Nenutil | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | |
69 | Frýdek-Místek | Eva Richtrová | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | |
18 | Příbram | Josef Řihák | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | |
75 | Karviná | Radek Sušil | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | |
33 | Děčín | Jaroslav Sykáček | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | |
15 | Pelhřimov | Milan Štěch | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | |
39 | Trutnov | Pavel Trpák | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | |
51 | Žďár nad Sázavou | Dagmar Zvěřinová | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | |
67 | Nový Jičín | Zdeněk Besta | ČSSD | 1 | ČSSD | orange | Česká strana sociálně demokratická | |
73 | Frýdek-Místek | Petr Gawlas | ČSSD | 1 | ČSSD | orange | Česká strana sociálně demokratická | |
76 | Kroměříž | Miloš Malý | ČSSD | 1 | ČSSD | orange | Česká strana sociálně demokratická | |
70 | Ostrava-město | Antonín Maštalíř | ČSSD | 1 | ČSSD | orange | Česká strana sociálně demokratická | |
40 | Kutná Hora | Jaromír Strnad | ČSSD | 1 | ČSSD | orange | Česká strana sociálně demokratická | |
79 | Hodonín | Zdeněk Škromach | ČSSD | 1 | ČSSD | orange | Česká strana sociálně demokratická | |
37 | Jičín | Josef Táborský | ČSSD | 1 | ČSSD | orange | Česká strana sociálně demokratická | |
7 | Plzeň-město | Dagmar Terelmešová | ČSSD | 1 | ČSSD | orange | Česká strana sociálně demokratická | |
61 | Olomouc | Martin Tesařík | ČSSD | 1 | ČSSD | orange | Česká strana sociálně demokratická | |
55 | Brno-město | Jan Žaloudík | BEZPP | 1 | ČSSD | orange | Česká strana sociálně demokratická | |
2 | Sokolov | Zdeněk Berka | ČSSD | 2 | ČSSD | orange | Česká strana sociálně demokratická | |
53 | Třebíč | František Bublan | BEZPP | 2 | ČSSD | orange | Česká strana sociálně demokratická | |
8 | Rokycany | Milada Emmerová | ČSSD | 2 | ČSSD | orange | Česká strana sociálně demokratická | |
47 | Náchod | Lubomír Franc | ČSSD | 2 | ČSSD | orange | Česká strana sociálně demokratická | |
56 | Břeclav | Jan Hajda | ČSSD | 2 | ČSSD | orange | Česká strana sociálně demokratická | |
38 | Mladá Boleslav | Jaromír Jermář | ČSSD | 2 | ČSSD | orange | Česká strana sociálně demokratická | |
11 | Domažlice | Jan Látka | ČSSD | 2 | ČSSD | orange | Česká strana sociálně demokratická | |
50 | Svitavy | Radko Martínek | ČSSD | 2 | ČSSD | orange | Česká strana sociálně demokratická | |
29 | Litoměřice | Hassan Mezian | ČSSD | 2 | ČSSD | orange | Česká strana sociálně demokratická | |
68 | Opava | Vladimír Plaček | ČSSD | 2 | ČSSD | orange | Česká strana sociálně demokratická | |
62 | Prostějov | Božena Sekaninová | ČSSD | 2 | ČSSD | orange | Česká strana sociálně demokratická | |
20 | Praha 4 | Eva Syková | BEZPP | 2 | ČSSD | orange | Česká strana sociálně demokratická | |
74 | Karviná | Petr Vícha | ČSSD | 2 | ČSSD | orange | Česká strana sociálně demokratická | |
60 | Brno-město | Miloš Janeček | nezjištěno | 0 | nez. | gray | nezařazení | |
42 | Kolín | Pavel Lebeda | BEZPP | 0 | nez. | gray | nezařazení | |
59 | Brno-město | Eliška Wagnerová | BEZPP | 2 | Zelení | green | Zelení | |
22 | Praha 10 | Ivana Cabrnochová | Zelení | 1 | Zelení | green | Zelení | |
26 | Praha 2 | Libor Michálek | BEZPP | 2 | Piráti | black | Piráti | |
12 | Strakonice | Miroslav Krejča | BEZPP | 0 | KDU-ČSL | yellow | Křesťansko-demokratická unie – Československá strana lidová | |
43 | Pardubice | Miluše Horská | BEZPP | 1 | KDU-ČSL | yellow | Křesťansko-demokratická unie – Československá strana lidová | |
58 | Brno-město | Stanislav Juránek | KDU-ČSL | 1 | KDU-ČSL | yellow | Křesťansko-demokratická unie – Československá strana lidová | |
46 | Ústí nad Orlicí | Petr Šilar | KDU-ČSL | 1 | KDU-ČSL | yellow | Křesťansko-demokratická unie – Československá strana lidová | |
77 | Vsetín | Jiří Čunek | KDU-ČSL | 2 | KDU-ČSL | yellow | Křesťansko-demokratická unie – Československá strana lidová | |
80 | Zlín | Patrik Kunčar | KDU-ČSL | 2 | KDU-ČSL | yellow | Křesťansko-demokratická unie – Československá strana lidová | |
1 | Karlovy Vary | Jan Horník | BEZPP | 1 | TOP09-STAN | purple | TOP09-STAN | |
65 | Šumperk | Zdeněk Brož | BEZPP | 2 | TOP09-STAN | purple | TOP09-STAN | |
41 | Benešov | Luděk Jeništa | BEZPP | 2 | TOP09-STAN | purple | TOP09-STAN | |
71 | Ostrava-město | Leopold Sulovský | BEZPP | 2 | TOP09-STAN | purple | TOP09-STAN | |
14 | České Budějovice | Jiří Šesták | HOPB | 2 | TOP09-STAN | purple | TOP09-STAN | |
24 | Praha 9 | Tomáš Kladívko | ODS | 0 | ODS | blue | Občanská demokratická strana | |
27 | Praha 1 | Zdeněk Schwarz | BEZPP | 0 | ODS | blue | Občanská demokratická strana | |
21 | Praha 5 | Miroslav Škaloud | ODS | 0 | ODS | blue | Občanská demokratická strana | |
25 | Praha 6 | Petr Bratský | ODS | 1 | ODS | blue | Občanská demokratická strana | |
13 | Tábor | Pavel Eybert | ODS | 1 | ODS | blue | Občanská demokratická strana | |
10 | Český Krumlov | Tomáš Jirsa | ODS | 1 | ODS | blue | Občanská demokratická strana | |
16 | Beroun | Jiří Oberfalzer | ODS | 1 | ODS | blue | Občanská demokratická strana | |
19 | Praha 11 | Milan Pešák | ODS | 1 | ODS | blue | Občanská demokratická strana | |
34 | Liberec | Přemysl Sobotka | ODS | 1 | ODS | blue | Občanská demokratická strana | |
28 | Mělník | Veronika Vrecionová | ODS | 1 | ODS | blue | Občanská demokratická strana | |
52 | Jihlava | Miloš Vystrčil | ODS | 1 | ODS | blue | Občanská demokratická strana | |
23 | Praha 8 | Daniela Filipiová | ODS | 2 | ODS | blue | Občanská demokratická strana | |
17 | Praha 12 | Tomáš Grulich | ODS | 2 | ODS | blue | Občanská demokratická strana | |
32 | Teplice | Jaroslav Kubera | ODS | 2 | ODS | blue | Občanská demokratická strana | |
35 | Jablonec nad Nisou | Jaroslav Zeman | ODS | 2 | ODS | blue | Občanská demokratická strana |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"color": "red", "abbreviation": "KS\u010cM", "name": "Komunistick\u00e1 strana \u010cech a Moravy", "people": [{"opacity": 1, "name": "Marta Bayerov\u00e1 - Znojmo<br/>Komunistick\u00e1 strana \u010cech a Moravy", "background": "red"}, {"opacity": 1, "name": "V\u00e1clav Homolka - Chomutov<br/>Komunistick\u00e1 strana \u010cech a Moravy", "background": "green"}]}, {"color": "#ff4444", "abbreviation": "S.cz", "name": "Severo\u010de\u0161i.cz", "people": [{"opacity": 1, "name": "Jaroslav Doubrava - \u00dast\u00ed nad Labem<br/>Severo\u010de\u0161i.cz", "background": "green"}]}, {"color": "#ff6666", "abbreviation": "nez.-S.cz", "name": "neza\u0159azen\u00ed (Severo\u010de\u0161i.cz)", "people": [{"opacity": 1, "name": "Alena Dernerov\u00e1 - Most<br/>neza\u0159azen\u00ed (Severo\u010de\u0161i.cz)", "background": "green"}]}, {"color": "#fdd7e4", "abbreviation": "nez.-SPO", "name": "neza\u0159ezen\u00ed (Strana pr\u00e1v ob\u010dan\u016f)", "people": [{"opacity": 1, "name": "Vladim\u00edr Dryml - Hradec Kr\u00e1lov\u00e9<br/>neza\u0159ezen\u00ed (Strana pr\u00e1v ob\u010dan\u016f)", "background": "red"}]}, {"color": "pink", "abbreviation": "SPO", "name": "Strana pr\u00e1v ob\u010dan\u016f", "people": [{"opacity": 1, "name": "Jaroslav Palas - Brunt\u00e1l<br/>Strana pr\u00e1v ob\u010dan\u016f", "background": "green"}, {"opacity": 1, "name": "Jozef Regec - Blansko<br/>Strana pr\u00e1v ob\u010dan\u016f", "background": "green"}, {"opacity": 1, "name": "Jan Veleba - Chrudim<br/>Strana pr\u00e1v ob\u010dan\u016f", "background": "green"}]}, {"color": "orange", "abbreviation": "\u010cSSD", "name": "\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "people": [{"opacity": 1, "name": "Miroslav Antl - Rychnov nad Kn\u011b\u017enou<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "red"}, {"opacity": 1, "name": "Ivo B\u00e1rek - Vy\u0161kov<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "red"}, {"opacity": 1, "name": "Ji\u0159\u00ed Bis - Plze\u0148-m\u011bsto<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "red"}, {"opacity": 1, "name": "Ji\u0159\u00ed Dienstbier - Kladno<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "red"}, {"opacity": 1, "name": "Hana Doupovcov\u00e1 - Uhersk\u00e9 Hradi\u0161t\u011b<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "red"}, {"opacity": 1, "name": "Alena Gajd\u016f\u0161kov\u00e1 - Zl\u00edn<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "red"}, {"opacity": 1, "name": "Petr Guziana - Ostrava-m\u011bsto<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "red"}, {"opacity": 1, "name": "Marcel Chl\u00e1dek - Louny<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "red"}, {"opacity": 1, "name": "Karel Kapoun - \u010cesk\u00e1 L\u00edpa<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "red"}, {"opacity": 1, "name": "Karel Koryt\u00e1\u0159 - Olomouc<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "red"}, {"opacity": 1, "name": "Ji\u0159\u00ed Lajtoch - P\u0159erov<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "red"}, {"opacity": 1, "name": "Miroslav Nenutil - Cheb<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "red"}, {"opacity": 1, "name": "Eva Richtrov\u00e1 - Fr\u00fddek-M\u00edstek<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "red"}, {"opacity": 1, "name": "Josef \u0158ih\u00e1k - P\u0159\u00edbram<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "red"}, {"opacity": 1, "name": "Radek Su\u0161il - Karvin\u00e1<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "red"}, {"opacity": 1, "name": "Jaroslav Syk\u00e1\u010dek - D\u011b\u010d\u00edn<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "red"}, {"opacity": 1, "name": "Milan \u0160t\u011bch - Pelh\u0159imov<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "red"}, {"opacity": 1, "name": "Pavel Trp\u00e1k - Trutnov<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "red"}, {"opacity": 1, "name": "Dagmar Zv\u011b\u0159inov\u00e1 - \u017d\u010f\u00e1r nad S\u00e1zavou<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "red"}, {"opacity": 1, "name": "Zden\u011bk Besta - Nov\u00fd Ji\u010d\u00edn<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "green"}, {"opacity": 1, "name": "Petr Gawlas - Fr\u00fddek-M\u00edstek<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "green"}, {"opacity": 1, "name": "Milo\u0161 Mal\u00fd - Krom\u011b\u0159\u00ed\u017e<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "green"}, {"opacity": 1, "name": "Anton\u00edn Ma\u0161tal\u00ed\u0159 - Ostrava-m\u011bsto<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "green"}, {"opacity": 1, "name": "Jarom\u00edr Strnad - Kutn\u00e1 Hora<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "green"}, {"opacity": 1, "name": "Zden\u011bk \u0160kromach - Hodon\u00edn<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "green"}, {"opacity": 1, "name": "Josef T\u00e1borsk\u00fd - Ji\u010d\u00edn<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "green"}, {"opacity": 1, "name": "Dagmar Terelme\u0161ov\u00e1 - Plze\u0148-m\u011bsto<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "green"}, {"opacity": 1, "name": "Martin Tesa\u0159\u00edk - Olomouc<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "green"}, {"opacity": 1, "name": "Jan \u017daloud\u00edk - Brno-m\u011bsto<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "green"}, {"opacity": 1, "name": "Zden\u011bk Berka - Sokolov<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "green"}, {"opacity": 1, "name": "Franti\u0161ek Bublan - T\u0159eb\u00ed\u010d<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "green"}, {"opacity": 1, "name": "Milada Emmerov\u00e1 - Rokycany<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "green"}, {"opacity": 1, "name": "Lubom\u00edr Franc - N\u00e1chod<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "green"}, {"opacity": 1, "name": "Jan Hajda - B\u0159eclav<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "green"}, {"opacity": 1, "name": "Jarom\u00edr Jerm\u00e1\u0159 - Mlad\u00e1 Boleslav<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "green"}, {"opacity": 1, "name": "Jan L\u00e1tka - Doma\u017elice<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "green"}, {"opacity": 1, "name": "Radko Mart\u00ednek - Svitavy<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "green"}, {"opacity": 1, "name": "Hassan Mezian - Litom\u011b\u0159ice<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "green"}, {"opacity": 1, "name": "Vladim\u00edr Pla\u010dek - Opava<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "green"}, {"opacity": 1, "name": "Bo\u017eena Sekaninov\u00e1 - Prost\u011bjov<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "green"}, {"opacity": 1, "name": "Eva Sykov\u00e1 - Praha 4<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "green"}, {"opacity": 1, "name": "Petr V\u00edcha - Karvin\u00e1<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "background": "green"}]}, {"color": "gray", "abbreviation": "nez.", "name": "neza\u0159azen\u00ed", "people": [{"opacity": 1, "name": "Milo\u0161 Jane\u010dek - Brno-m\u011bsto<br/>neza\u0159azen\u00ed", "background": "red"}, {"opacity": 1, "name": "Pavel Lebeda - Kol\u00edn<br/>neza\u0159azen\u00ed", "background": "red"}]}, {"color": "green", "abbreviation": "Zelen\u00ed", "name": "Zelen\u00ed", "people": [{"opacity": 1, "name": "Eli\u0161ka Wagnerov\u00e1 - Brno-m\u011bsto<br/>Zelen\u00ed", "background": "green"}, {"opacity": 1, "name": "Ivana Cabrnochov\u00e1 - Praha 10<br/>Zelen\u00ed", "background": "green"}]}, {"color": "black", "abbreviation": "Pir\u00e1ti", "name": "Pir\u00e1ti", "people": [{"opacity": 1, "name": "Libor Mich\u00e1lek - Praha 2<br/>Pir\u00e1ti", "background": "green"}]}, {"color": "yellow", "abbreviation": "KDU-\u010cSL", "name": "K\u0159es\u0165ansko-demokratick\u00e1 unie \u2013 \u010ceskoslovensk\u00e1 strana lidov\u00e1", "people": [{"opacity": 1, "name": "Miroslav Krej\u010da - Strakonice<br/>K\u0159es\u0165ansko-demokratick\u00e1 unie \u2013 \u010ceskoslovensk\u00e1 strana lidov\u00e1", "background": "red"}, {"opacity": 1, "name": "Milu\u0161e Horsk\u00e1 - Pardubice<br/>K\u0159es\u0165ansko-demokratick\u00e1 unie \u2013 \u010ceskoslovensk\u00e1 strana lidov\u00e1", "background": "green"}, {"opacity": 1, "name": "Stanislav Jur\u00e1nek - Brno-m\u011bsto<br/>K\u0159es\u0165ansko-demokratick\u00e1 unie \u2013 \u010ceskoslovensk\u00e1 strana lidov\u00e1", "background": "green"}, {"opacity": 1, "name": "Petr \u0160ilar - \u00dast\u00ed nad Orlic\u00ed<br/>K\u0159es\u0165ansko-demokratick\u00e1 unie \u2013 \u010ceskoslovensk\u00e1 strana lidov\u00e1", "background": "green"}, {"opacity": 1, "name": "Ji\u0159\u00ed \u010cunek - Vset\u00edn<br/>K\u0159es\u0165ansko-demokratick\u00e1 unie \u2013 \u010ceskoslovensk\u00e1 strana lidov\u00e1", "background": "green"}, {"opacity": 1, "name": "Patrik Kun\u010dar - Zl\u00edn<br/>K\u0159es\u0165ansko-demokratick\u00e1 unie \u2013 \u010ceskoslovensk\u00e1 strana lidov\u00e1", "background": "green"}]}, {"color": "purple", "abbreviation": "TOP09-STAN", "name": "TOP09-STAN", "people": [{"opacity": 1, "name": "Jan Horn\u00edk - Karlovy Vary<br/>TOP09-STAN", "background": "green"}, {"opacity": 1, "name": "Zden\u011bk Bro\u017e - \u0160umperk<br/>TOP09-STAN", "background": "green"}, {"opacity": 1, "name": "Lud\u011bk Jeni\u0161ta - Bene\u0161ov<br/>TOP09-STAN", "background": "green"}, {"opacity": 1, "name": "Leopold Sulovsk\u00fd - Ostrava-m\u011bsto<br/>TOP09-STAN", "background": "green"}, {"opacity": 1, "name": "Ji\u0159\u00ed \u0160est\u00e1k - \u010cesk\u00e9 Bud\u011bjovice<br/>TOP09-STAN", "background": "green"}]}, {"color": "blue", "abbreviation": "ODS", "name": "Ob\u010dansk\u00e1 demokratick\u00e1 strana", "people": [{"opacity": 1, "name": "Tom\u00e1\u0161 Klad\u00edvko - Praha 9<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana", "background": "red"}, {"opacity": 1, "name": "Zden\u011bk Schwarz - Praha 1<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana", "background": "red"}, {"opacity": 1, "name": "Miroslav \u0160kaloud - Praha 5<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana", "background": "red"}, {"opacity": 1, "name": "Petr Bratsk\u00fd - Praha 6<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana", "background": "green"}, {"opacity": 1, "name": "Pavel Eybert - T\u00e1bor<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana", "background": "green"}, {"opacity": 1, "name": "Tom\u00e1\u0161 Jirsa - \u010cesk\u00fd Krumlov<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana", "background": "green"}, {"opacity": 1, "name": "Ji\u0159\u00ed Oberfalzer - Beroun<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana", "background": "green"}, {"opacity": 1, "name": "Milan Pe\u0161\u00e1k - Praha 11<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana", "background": "green"}, {"opacity": 1, "name": "P\u0159emysl Sobotka - Liberec<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana", "background": "green"}, {"opacity": 1, "name": "Veronika Vrecionov\u00e1 - M\u011bln\u00edk<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana", "background": "green"}, {"opacity": 1, "name": "Milo\u0161 Vystr\u010dil - Jihlava<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana", "background": "green"}, {"opacity": 1, "name": "Daniela Filipiov\u00e1 - Praha 8<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana", "background": "green"}, {"opacity": 1, "name": "Tom\u00e1\u0161 Grulich - Praha 12<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana", "background": "green"}, {"opacity": 1, "name": "Jaroslav Kubera - Teplice<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana", "background": "green"}, {"opacity": 1, "name": "Jaroslav Zeman - Jablonec nad Nisou<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana", "background": "green"}]}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script src="https://code.jquery.com/jquery-1.11.1.js"></script> | |
<style> | |
/*http://www.d3noob.org/2013/01/adding-drop-shadow-to-allow-text-to.html*/ | |
text.shadow { | |
stroke: gray; | |
stroke-width: 1px; | |
opacity: 0.9; | |
} | |
/* D3 tips */ | |
.d3-tip { | |
line-height: 1; | |
font-weight: bold; | |
padding: 12px; | |
background: rgba(0, 0, 0, 0.8); | |
color: #fff; | |
border-radius: 2px; | |
} | |
/* Creates a small triangle extender for the tooltip */ | |
/*.d3-tip:after { | |
box-sizing: border-box; | |
display: inline; | |
font-size: 10px; | |
width: 100%; | |
line-height: 1; | |
color: rgba(0, 0, 0, 0.8); | |
content: "\25BC"; | |
position: absolute; | |
text-align: center; | |
}*/ | |
/* Style northward tooltips differently */ | |
.d3-tip.n:after { | |
margin: -1px 0 0 0; | |
top: 100%; | |
left: 0; | |
} | |
.stronger { | |
color: yellow; | |
} | |
</style> | |
<script src="d3.hemicycle.js"></script> | |
<script src="d3.tip.js"></script> | |
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet"> | |
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootswatch/3.2.0/cerulean/bootstrap.min.css"> | |
</head> | |
<body> | |
<div id="chart" style="width:400px;margin-left:100px;margin-top:35px;"></div> | |
<div id="legend" style="width:400px;padding:15px;margin-left:100px;"> | |
<div class="row" style="text-align:center">Legenda:</div> | |
<div class="row" style="border-bottom:1px solid #ccc;"> | |
<div class="col-xs-2"></div> | |
<div class="col-xs-5"><i class="fa fa-bolt" style="color:red;font-size:20px;"> </i><strong> Končí mandát</strong></div> | |
<div class="col-xs-5"><i class="fa fa-certificate" style="color:green;font-size:20px;"> </i> Pokračuje</div> | |
</div> | |
<div class="row" id="legendin"> | |
</div> | |
</div> | |
<script type="text/javascript"> | |
var json = (function () { | |
var json = null; | |
$.ajax({ | |
'async': false, | |
'global': false, | |
'url': "./hemicycle.json", | |
'dataType': "json", | |
'success': function (data) { | |
json = data; | |
} | |
}); | |
return json; | |
})(); | |
var hemicycle = [{ | |
"n":[9,13,16,20,23], | |
"gap": 1.20, | |
"widthIcon": 0.34, | |
"width": 400, | |
"groups": json | |
}]; | |
/* Initialize tooltip */ | |
tip = d3.tip().attr("class", "d3-tip").html(function(d) { | |
return "<span class=\'stronger\'>" + d["name"] + "</span><br>"; | |
}); | |
var w=400,h=205, | |
svg=d3.select("#chart") | |
.append("svg") | |
.attr("width",w) | |
.attr("height",h); | |
var hc = d3.hemicycle() | |
.n(function(d) {return d.n;}) | |
.gap(function(d) {return d.gap;}) | |
.widthIcon(function(d) {return d.widthIcon;}) | |
.width(function(d) {return d.width;}) | |
.groups(function(d) {return d.groups;}); | |
var item = svg.selectAll(".hc") | |
.data(hemicycle) | |
.enter() | |
.append("svg:g") | |
.call(hc); | |
/* Invoke the tip in the context of your visualization */ | |
svg.call(tip); | |
// Add tooltip div | |
var div = d3.select("body").append("div") | |
.attr("class", "tooltip") | |
.style("opacity", 1e-6); | |
inhtml = ''; | |
for (k in json) { | |
if (k == 12) break; | |
group = json[k]; | |
if (k % 4 == 0) { | |
inhtml = inhtml + "<div class='row'>"; | |
} | |
inhtml = inhtml + '<div class="col-xs-3"><i class="fa fa-user" style="color:' + group['color'] + ';font-size:15px;"> </i>' + group["abbreviation"] + "</div> "; | |
if (k % 4 == 3) { | |
inhtml = inhtml + "</div>"; | |
} | |
} | |
$("#legendin").html(inhtml) | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment