Last active
August 29, 2015 14:07
-
-
Save michalskop/3b8fa0776a8dbd16aaf2 to your computer and use it in GitHub Desktop.
CZ: Senate 2014, after elections
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 = "green" | |
else: | |
op = "gray" | |
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
5 | Chomutov | Václav Homolka | KSČM | 2 | KSČM | red | Komunistická strana Čech a Moravy | 1 | |
---|---|---|---|---|---|---|---|---|---|
31 | Ústí nad Labem | Jaroslav Doubrava | S.cz | 1 | S.cz | #ff4444 | Severočeši.cz | 2 | |
4 | Most | Alena Dernerová | BEZPP | 1 | S.cz | #ff4444 | nezařazení (Severočeši.cz) | 3 | |
78 | Zlín | František Čuba | SPO | 0 | SPO | pink | Strana práv občanů | 4 | |
49 | Blansko | Jozef Regec | BEZPP | 1 | SPO | pink | Strana práv občanů | 4 | |
64 | Bruntál | Jaroslav Palas | nezjištěno | 1 | SPO | pink | Strana práv občanů | 4 | |
44 | Chrudim | Jan Veleba | BEZPP | 2 | SPO | pink | Strana práv občanů | 4 | |
3 | Cheb | Miroslav Nenutil | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
12 | Strakonice | Karel Kratochvíle | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
15 | Pelhřimov | Milan Štěch | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
30 | Kladno | Jiří Dienstbier | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
42 | Kolín | Emilie Třísková | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
45 | Hradec Králové | Jaroslav Malá | BEZPP | 0 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
48 | Rychnov nad Kněžnou | Miroslav Antl | BEZPP | 0 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
54 | Znojmo | Pavel štohl | BEZPP | 0 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
57 | Vyškov | Ivo Bárek | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
75 | Karviná | Radek Sušil | ČSSD | 0 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
7 | Plzeň-město | Dagmar Terelmešová | ČSSD | 1 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
37 | Jičín | Josef Táborský | ČSSD | 1 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
40 | Kutná Hora | Jaromír Strnad | ČSSD | 1 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
55 | Brno-město | Jan Žaloudík | BEZPP | 1 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
61 | Olomouc | Martin Tesařík | ČSSD | 1 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
67 | Nový Jičín | Zdeněk Besta | ČSSD | 1 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
70 | Ostrava-město | Antonín Maštalíř | ČSSD | 1 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
73 | Frýdek-Místek | Petr Gawlas | ČSSD | 1 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
76 | Kroměříž | Miloš Malý | ČSSD | 1 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
79 | Hodonín | Zdeněk Škromach | ČSSD | 1 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
2 | Sokolov | Zdeněk Berka | ČSSD | 2 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
8 | Rokycany | Milada Emmerová | ČSSD | 2 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
11 | Domažlice | Jan Látka | ČSSD | 2 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
20 | Praha 4 | Eva Syková | BEZPP | 2 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
29 | Litoměřice | Hassan Mezian | ČSSD | 2 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
38 | Mladá Boleslav | Jaromír Jermář | ČSSD | 2 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
47 | Náchod | Lubomír Franc | ČSSD | 2 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
50 | Svitavy | Radko Martínek | ČSSD | 2 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
53 | Třebíč | František Bublan | BEZPP | 2 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
56 | Břeclav | Jan Hajda | ČSSD | 2 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
62 | Prostějov | Božena Sekaninová | ČSSD | 2 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
68 | Opava | Vladimír Plaček | ČSSD | 2 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
74 | Karviná | Petr Vícha | ČSSD | 2 | ČSSD | orange | Česká strana sociálně demokratická | 5 | |
26 | Praha 2 | Libor Michálek | BEZPP | 2 | Piráti | black | Piráti | 6 | |
21 | Praha 5 | Václav Láska | BEZPP | 0 | Zelení | green | Zelení | 7 | |
63 | Přerov | Jitka Seitlová | BEZPP | 0 | Zelení | green | Zelení | 7 | |
22 | Praha 10 | Ivana Cabrnochová | Zelení | 1 | Zelení | green | Zelení | 7 | |
59 | Brno-město | Eliška Wagnerová | BEZPP | 2 | Zelení | green | Zelení | 7 | |
27 | Praha 1 | Václav Hampl | BEZPP | 0 | KDU-ČSL | yellow | Křesťansko-demokratická unie – Československá strana lidová | 8 | |
51 | Žďár nad Sázavou | František Bradáč | KDU-ČSL | 0 | KDU-ČSL | yellow | Křesťansko-demokratická unie – Československá strana lidová | 8 | |
60 | Brno-město | Zdeněk Papoušek | BEZPP | 0 | KDU-ČSL | yellow | Křesťansko-demokratická unie – Československá strana lidová | 8 | |
66 | Olomouc | Alena Šromová | KDU-ČSL | 0 | KDU-ČSL | yellow | Křesťansko-demokratická unie – Československá strana lidová | 8 | |
69 | Frýdek-Místek | Jiří Carbol | KDU-ČSL | 0 | KDU-ČSL | yellow | Křesťansko-demokratická unie – Československá strana lidová | 8 | |
43 | Pardubice | Miluše Horská | BEZPP | 1 | KDU-ČSL | yellow | Křesťansko-demokratická unie – Československá strana lidová | 8 | |
46 | Ústí nad Orlicí | Petr Šilar | KDU-ČSL | 1 | KDU-ČSL | yellow | Křesťansko-demokratická unie – Československá strana lidová | 8 | |
58 | Brno-město | Stanislav Juránek | KDU-ČSL | 1 | KDU-ČSL | yellow | Křesťansko-demokratická unie – Československá strana lidová | 8 | |
77 | Vsetín | Jiří Čunek | KDU-ČSL | 2 | KDU-ČSL | yellow | Křesťansko-demokratická unie – Československá strana lidová | 8 | |
80 | Zlín | Patrik Kunčar | KDU-ČSL | 2 | KDU-ČSL | yellow | Křesťansko-demokratická unie – Československá strana lidová | 8 | |
6 | Louny | Zdeňka Hamousová | BEZPP | 0 | ANO | #0bb | ANO 2011 | 8.5 | |
24 | Praha 9 | Zuzana Baudyšová | BEZPP | 0 | ANO | #0bb | ANO 2011 | 8.5 | |
39 | Trutnov | Adolf Klepš | BEZPP | 0 | ANO | #0bb | ANO 2011 | 8.5 | |
72 | Ostrava-město | Peter Koliba | BEZPP | 0 | ANO | #0bb | ANO 2011 | 8.5 | |
36 | Česká Lípa | Jiří Vosecký | SLK | 0 | SLK | purple | Starostové pro Liberecký kraj | 9 | |
33 | Děčín | Jaroslav Sykáček | BEZPP | 0 | TOPSTAN | purple | TOP09-STAN | 9 | |
1 | Karlovy Vary | Jan Horník | BEZPP | 1 | TOPSTAN | purple | TOP09-STAN | 9 | |
14 | České Budějovice | Jiří Šesták | HOPB | 2 | TOPSTAN | purple | TOP09-STAN | 9 | |
41 | Benešov | Luděk Jeništa | BEZPP | 2 | TOPSTAN | purple | TOP09-STAN | 9 | |
65 | Šumperk | Zdeněk Brož | BEZPP | 2 | TOPSTAN | purple | TOP09-STAN | 9 | |
71 | Ostrava-město | Leopold Sulovský | BEZPP | 2 | TOPSTAN | purple | TOP09-STAN | 9 | |
81 | Uherské Hradiště | Ivo Valenta | ScČR | 0 | SsČR | #FFF380 | Strana soukromníků ČR | 10 | |
9 | Plzeň-město | Lumír Aschenbrenner | ODS | 0 | ODS | blue | Občanská demokratická strana | 11 | |
18 | Příbram | Jiří Burian | ODS | 0 | ODS | blue | Občanská demokratická strana | 11 | |
10 | Český Krumlov | Tomáš Jirsa | ODS | 1 | ODS | blue | Občanská demokratická strana | 11 | |
13 | Tábor | Pavel Eybert | ODS | 1 | ODS | blue | Občanská demokratická strana | 11 | |
16 | Beroun | Jiří Oberfalzer | ODS | 1 | ODS | blue | Občanská demokratická strana | 11 | |
19 | Praha 11 | Milan Pešák | ODS | 1 | ODS | blue | Občanská demokratická strana | 11 | |
25 | Praha 6 | Petr Bratský | ODS | 1 | ODS | blue | Občanská demokratická strana | 11 | |
28 | Mělník | Veronika Vrecionová | ODS | 1 | ODS | blue | Občanská demokratická strana | 11 | |
34 | Liberec | Přemysl Sobotka | ODS | 1 | ODS | blue | Občanská demokratická strana | 11 | |
52 | Jihlava | Miloš Vystrčil | ODS | 1 | ODS | blue | Občanská demokratická strana | 11 | |
17 | Praha 12 | Tomáš Grulich | ODS | 2 | ODS | blue | Občanská demokratická strana | 11 | |
23 | Praha 8 | Daniela Filipiová | ODS | 2 | ODS | blue | Občanská demokratická strana | 11 | |
32 | Teplice | Jaroslav Kubera | ODS | 2 | ODS | blue | Občanská demokratická strana | 11 | |
35 | Jablonec nad Nisou | Jaroslav Zeman | ODS | 2 | ODS | blue | Občanská demokratická strana | 11 |
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", "people": [{"background": "gray", "opacity": 1, "name": "V\u00e1clav Homolka - Chomutov<br/>Komunistick\u00e1 strana \u010cech a Moravy"}], "name": "Komunistick\u00e1 strana \u010cech a Moravy", "abbreviation": "KS\u010cM"}, {"color": "#ff4444", "people": [{"background": "gray", "opacity": 1, "name": "Jaroslav Doubrava - \u00dast\u00ed nad Labem<br/>Severo\u010de\u0161i.cz"}, {"background": "gray", "opacity": 1, "name": "Alena Dernerov\u00e1 - Most<br/>neza\u0159azen\u00ed (Severo\u010de\u0161i.cz)"}], "name": "Severo\u010de\u0161i.cz", "abbreviation": "S.cz"}, {"color": "pink", "people": [{"background": "green", "opacity": 1, "name": "Franti\u0161ek \u010cuba - Zl\u00edn<br/>Strana pr\u00e1v ob\u010dan\u016f"}, {"background": "gray", "opacity": 1, "name": "Jozef Regec - Blansko<br/>Strana pr\u00e1v ob\u010dan\u016f"}, {"background": "gray", "opacity": 1, "name": "Jaroslav Palas - Brunt\u00e1l<br/>Strana pr\u00e1v ob\u010dan\u016f"}, {"background": "gray", "opacity": 1, "name": "Jan Veleba - Chrudim<br/>Strana pr\u00e1v ob\u010dan\u016f"}], "name": "Strana pr\u00e1v ob\u010dan\u016f", "abbreviation": "SPO"}, {"color": "orange", "people": [{"background": "green", "opacity": 1, "name": "Miroslav Nenutil - Cheb<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "green", "opacity": 1, "name": "Karel Kratochv\u00edle - Strakonice<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "green", "opacity": 1, "name": "Milan \u0160t\u011bch - Pelh\u0159imov<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "green", "opacity": 1, "name": "Ji\u0159\u00ed Dienstbier - Kladno<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "green", "opacity": 1, "name": "Emilie T\u0159\u00edskov\u00e1 - Kol\u00edn<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "green", "opacity": 1, "name": "Jaroslav Mal\u00e1 - Hradec Kr\u00e1lov\u00e9<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "green", "opacity": 1, "name": "Miroslav Antl - Rychnov nad Kn\u011b\u017enou<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "green", "opacity": 1, "name": "Pavel \u0161tohl - Znojmo<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "green", "opacity": 1, "name": "Ivo B\u00e1rek - Vy\u0161kov<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "green", "opacity": 1, "name": "Radek Su\u0161il - Karvin\u00e1<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "gray", "opacity": 1, "name": "Dagmar Terelme\u0161ov\u00e1 - Plze\u0148-m\u011bsto<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "gray", "opacity": 1, "name": "Josef T\u00e1borsk\u00fd - Ji\u010d\u00edn<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "gray", "opacity": 1, "name": "Jarom\u00edr Strnad - Kutn\u00e1 Hora<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "gray", "opacity": 1, "name": "Jan \u017daloud\u00edk - Brno-m\u011bsto<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "gray", "opacity": 1, "name": "Martin Tesa\u0159\u00edk - Olomouc<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "gray", "opacity": 1, "name": "Zden\u011bk Besta - Nov\u00fd Ji\u010d\u00edn<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "gray", "opacity": 1, "name": "Anton\u00edn Ma\u0161tal\u00ed\u0159 - Ostrava-m\u011bsto<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "gray", "opacity": 1, "name": "Petr Gawlas - Fr\u00fddek-M\u00edstek<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "gray", "opacity": 1, "name": "Milo\u0161 Mal\u00fd - Krom\u011b\u0159\u00ed\u017e<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "gray", "opacity": 1, "name": "Zden\u011bk \u0160kromach - Hodon\u00edn<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "gray", "opacity": 1, "name": "Zden\u011bk Berka - Sokolov<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "gray", "opacity": 1, "name": "Milada Emmerov\u00e1 - Rokycany<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "gray", "opacity": 1, "name": "Jan L\u00e1tka - Doma\u017elice<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "gray", "opacity": 1, "name": "Eva Sykov\u00e1 - Praha 4<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "gray", "opacity": 1, "name": "Hassan Mezian - Litom\u011b\u0159ice<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "gray", "opacity": 1, "name": "Jarom\u00edr Jerm\u00e1\u0159 - Mlad\u00e1 Boleslav<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "gray", "opacity": 1, "name": "Lubom\u00edr Franc - N\u00e1chod<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "gray", "opacity": 1, "name": "Radko Mart\u00ednek - Svitavy<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "gray", "opacity": 1, "name": "Franti\u0161ek Bublan - T\u0159eb\u00ed\u010d<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "gray", "opacity": 1, "name": "Jan Hajda - B\u0159eclav<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "gray", "opacity": 1, "name": "Bo\u017eena Sekaninov\u00e1 - Prost\u011bjov<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "gray", "opacity": 1, "name": "Vladim\u00edr Pla\u010dek - Opava<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}, {"background": "gray", "opacity": 1, "name": "Petr V\u00edcha - Karvin\u00e1<br/>\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1"}], "name": "\u010cesk\u00e1 strana soci\u00e1ln\u011b\u00a0demokratick\u00e1", "abbreviation": "\u010cSSD"}, {"color": "black", "people": [{"background": "gray", "opacity": 1, "name": "Libor Mich\u00e1lek - Praha 2<br/>Pir\u00e1ti"}], "name": "Pir\u00e1ti", "abbreviation": "Pir\u00e1ti"}, {"color": "green", "people": [{"background": "green", "opacity": 1, "name": "V\u00e1clav L\u00e1ska - Praha 5<br/>Zelen\u00ed"}, {"background": "green", "opacity": 1, "name": "Jitka Seitlov\u00e1 - P\u0159erov<br/>Zelen\u00ed"}, {"background": "gray", "opacity": 1, "name": "Ivana Cabrnochov\u00e1 - Praha 10<br/>Zelen\u00ed"}, {"background": "gray", "opacity": 1, "name": "Eli\u0161ka Wagnerov\u00e1 - Brno-m\u011bsto<br/>Zelen\u00ed"}], "name": "Zelen\u00ed", "abbreviation": "Zelen\u00ed"}, {"color": "yellow", "people": [{"background": "green", "opacity": 1, "name": "V\u00e1clav Hampl - Praha 1<br/>K\u0159es\u0165ansko-demokratick\u00e1 unie \u2013 \u010ceskoslovensk\u00e1 strana lidov\u00e1"}, {"background": "green", "opacity": 1, "name": "Franti\u0161ek Brad\u00e1\u010d - \u017d\u010f\u00e1r nad S\u00e1zavou<br/>K\u0159es\u0165ansko-demokratick\u00e1 unie \u2013 \u010ceskoslovensk\u00e1 strana lidov\u00e1"}, {"background": "green", "opacity": 1, "name": "Zden\u011bk Papou\u0161ek - Brno-m\u011bsto<br/>K\u0159es\u0165ansko-demokratick\u00e1 unie \u2013 \u010ceskoslovensk\u00e1 strana lidov\u00e1"}, {"background": "green", "opacity": 1, "name": "Alena \u0160romov\u00e1 - Olomouc<br/>K\u0159es\u0165ansko-demokratick\u00e1 unie \u2013 \u010ceskoslovensk\u00e1 strana lidov\u00e1"}, {"background": "green", "opacity": 1, "name": "Ji\u0159\u00ed Carbol - Fr\u00fddek-M\u00edstek<br/>K\u0159es\u0165ansko-demokratick\u00e1 unie \u2013 \u010ceskoslovensk\u00e1 strana lidov\u00e1"}, {"background": "gray", "opacity": 1, "name": "Milu\u0161e Horsk\u00e1 - Pardubice<br/>K\u0159es\u0165ansko-demokratick\u00e1 unie \u2013 \u010ceskoslovensk\u00e1 strana lidov\u00e1"}, {"background": "gray", "opacity": 1, "name": "Petr \u0160ilar - \u00dast\u00ed nad Orlic\u00ed<br/>K\u0159es\u0165ansko-demokratick\u00e1 unie \u2013 \u010ceskoslovensk\u00e1 strana lidov\u00e1"}, {"background": "gray", "opacity": 1, "name": "Stanislav Jur\u00e1nek - Brno-m\u011bsto<br/>K\u0159es\u0165ansko-demokratick\u00e1 unie \u2013 \u010ceskoslovensk\u00e1 strana lidov\u00e1"}, {"background": "gray", "opacity": 1, "name": "Ji\u0159\u00ed \u010cunek - Vset\u00edn<br/>K\u0159es\u0165ansko-demokratick\u00e1 unie \u2013 \u010ceskoslovensk\u00e1 strana lidov\u00e1"}, {"background": "gray", "opacity": 1, "name": "Patrik Kun\u010dar - Zl\u00edn<br/>K\u0159es\u0165ansko-demokratick\u00e1 unie \u2013 \u010ceskoslovensk\u00e1 strana lidov\u00e1"}], "name": "K\u0159es\u0165ansko-demokratick\u00e1 unie \u2013 \u010ceskoslovensk\u00e1 strana lidov\u00e1", "abbreviation": "KDU-\u010cSL"}, {"color": "#0bb", "people": [{"background": "green", "opacity": 1, "name": "Zde\u0148ka Hamousov\u00e1 - Louny<br/>ANO 2011"}, {"background": "green", "opacity": 1, "name": "Zuzana Baudy\u0161ov\u00e1 - Praha 9<br/>ANO 2011"}, {"background": "green", "opacity": 1, "name": "Adolf Klep\u0161 - Trutnov<br/>ANO 2011"}, {"background": "green", "opacity": 1, "name": "Peter Koliba - Ostrava-m\u011bsto<br/>ANO 2011"}], "name": "ANO 2011", "abbreviation": "ANO"}, {"color": "purple", "people": [{"background": "green", "opacity": 1, "name": "Ji\u0159\u00ed Voseck\u00fd - \u010cesk\u00e1 L\u00edpa<br/>Starostov\u00e9 pro Libereck\u00fd kraj"}], "name": "Starostov\u00e9 pro Libereck\u00fd kraj", "abbreviation": "SLK"}, {"color": "purple", "people": [{"background": "green", "opacity": 1, "name": "Jaroslav Syk\u00e1\u010dek - D\u011b\u010d\u00edn<br/>TOP09-STAN"}, {"background": "gray", "opacity": 1, "name": "Jan Horn\u00edk - Karlovy Vary<br/>TOP09-STAN"}, {"background": "gray", "opacity": 1, "name": "Ji\u0159\u00ed \u0160est\u00e1k - \u010cesk\u00e9 Bud\u011bjovice<br/>TOP09-STAN"}, {"background": "gray", "opacity": 1, "name": "Lud\u011bk Jeni\u0161ta - Bene\u0161ov<br/>TOP09-STAN"}, {"background": "gray", "opacity": 1, "name": "Zden\u011bk Bro\u017e - \u0160umperk<br/>TOP09-STAN"}, {"background": "gray", "opacity": 1, "name": "Leopold Sulovsk\u00fd - Ostrava-m\u011bsto<br/>TOP09-STAN"}], "name": "TOP09-STAN", "abbreviation": "TOPSTAN"}, {"color": "#FFF380", "people": [{"background": "green", "opacity": 1, "name": "Ivo Valenta - Uhersk\u00e9 Hradi\u0161t\u011b<br/>Strana soukromn\u00edk\u016f \u010cR"}], "name": "Strana soukromn\u00edk\u016f \u010cR", "abbreviation": "Ss\u010cR"}, {"color": "blue", "people": [{"background": "green", "opacity": 1, "name": "Lum\u00edr Aschenbrenner - Plze\u0148-m\u011bsto<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana"}, {"background": "green", "opacity": 1, "name": "Ji\u0159\u00ed Burian - P\u0159\u00edbram<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana"}, {"background": "gray", "opacity": 1, "name": "Tom\u00e1\u0161 Jirsa - \u010cesk\u00fd Krumlov<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana"}, {"background": "gray", "opacity": 1, "name": "Pavel Eybert - T\u00e1bor<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana"}, {"background": "gray", "opacity": 1, "name": "Ji\u0159\u00ed Oberfalzer - Beroun<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana"}, {"background": "gray", "opacity": 1, "name": "Milan Pe\u0161\u00e1k - Praha 11<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana"}, {"background": "gray", "opacity": 1, "name": "Petr Bratsk\u00fd - Praha 6<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana"}, {"background": "gray", "opacity": 1, "name": "Veronika Vrecionov\u00e1 - M\u011bln\u00edk<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana"}, {"background": "gray", "opacity": 1, "name": "P\u0159emysl Sobotka - Liberec<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana"}, {"background": "gray", "opacity": 1, "name": "Milo\u0161 Vystr\u010dil - Jihlava<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana"}, {"background": "gray", "opacity": 1, "name": "Tom\u00e1\u0161 Grulich - Praha 12<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana"}, {"background": "gray", "opacity": 1, "name": "Daniela Filipiov\u00e1 - Praha 8<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana"}, {"background": "gray", "opacity": 1, "name": "Jaroslav Kubera - Teplice<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana"}, {"background": "gray", "opacity": 1, "name": "Jaroslav Zeman - Jablonec nad Nisou<br/>Ob\u010dansk\u00e1 demokratick\u00e1 strana"}], "name": "Ob\u010dansk\u00e1 demokratick\u00e1 strana", "abbreviation": "ODS"}] |
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-certificate" style="color:green;font-size:20px;"> </i><strong> Nově zvolený</strong></div> | |
<div class="col-xs-5"><i class="fa fa-certificate" style="color:gray;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:13px;"> </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