Permalink
Browse files

Added france-elections example

  • Loading branch information...
bjornd committed Sep 29, 2012
1 parent e5f1228 commit 85e370a9788d8588583edfa0d687bd9b55653f9e
@@ -0,0 +1 @@
+{"year2012":{"candidate1":"Hollande","candidate2":"Sarkozy","results":{"FR-J":1,"FR-G":2,"FR-S":1,"FR-Q":1,"FR-F":2,"FR-P":1,"FR-D":1,"FR-O":1,"FR-M":2,"FR-A":2,"FR-I":2,"FR-R":1,"FR-E":1,"FR-T":1,"FR-B":1,"FR-N":1,"FR-L":1,"FR-V":2,"FR-C":1,"FR-K":1,"FR-U":2,"FR-H":2,"FR-GP":1,"FR-MQ":1,"FR-GF":1,"FR-YT":2}},"year2007":{"candidate1":"Sarkozy","candidate2":"Royal","results":{"FR-J":1,"FR-G":1,"FR-S":1,"FR-Q":1,"FR-F":1,"FR-P":1,"FR-D":1,"FR-O":1,"FR-M":1,"FR-A":1,"FR-I":1,"FR-R":1,"FR-E":2,"FR-T":2,"FR-B":2,"FR-N":2,"FR-L":2,"FR-V":1,"FR-C":2,"FR-K":1,"FR-U":1,"FR-H":1,"FR-GP":2,"FR-MQ":2,"FR-GF":1,"FR-YT":2}}}
@@ -0,0 +1,31 @@
+Île de France 52.49 47.51
+Champagne-Ardenne 58.53 41.47
+Picardie 54.45 45.55
+Haute-Normandie 52.47 47.53
+Centre 55.02 44.98
+Basse-Normandie 54.22 45.78
+Bourgogne 54.28 45.72
+Nord - Pas-de-Calais 50.31 49.69
+Lorraine 54.65 45.35
+Alsace 65.5 34.5
+Franche-Comté 55.51 44.49
+Pays de la Loire 51.73 48.27
+Bretagne 47.38 52.62
+Poitou-Charentes 48.74 51.26
+Aquitaine 48.35 51.65
+Midi-Pyrénées 46.71 53.29
+Limousin 45.42 54.58
+Rhône-Alpes 56.31 43.69
+Auvergne 49.37 50.63
+Languedoc-Roussillon 54.1 45.9
+Provence-Alpes-Côte d'Azur 61.84 38.16
+Corse 60.12 39.88
+Gaudeloupe 49.17 50.83
+Martinique 39.48 60.52
+Guyane 53.08 46.92
+Réunion 36.43 63.57
+Sainte Pierre et Miquelon 39.14 60.86
+Mayotte 39.96 60.04
+Wallis et Futuna 50.17 49.83
+Polynesie Francaise 51.9 48.1
+Nouvelle Caledonie 62.98 37.02
@@ -0,0 +1,33 @@
+Île de France 53.32 46.68
+Champagne-Ardenne 45.89 54.11
+Picardie 50.95 49.05
+Haute-Normandie 52.55 47.45
+Centre 49.44 50.56
+Basse-Normandie 50.83 49.17
+Bourgogne 50.74 49.26
+Nord - Pas-de-Calais 54.13 45.87
+Lorraine 48.9 51.1
+Alsace 36.6 63.4
+Franche-Comté 49.01 50.99
+Pays de la Loire 51.13 48.87
+Bretagne 56.35 43.65
+Poitou-Charentes 55.51 44.49
+Aquitaine 56.57 43.43
+Midi-Pyrénées 57.94 42.06
+Limousin 63.78 36.22
+Rhône-Alpes 47.99 52.01
+Auvergne 56.91 43.09
+Languedoc-Roussillon 51.16 48.84
+Provence-Alpes-Côte d'Azur 42.4 57.6
+Corse 44.13 55.87
+Gaudeloupe 71.94 28.06
+Martinique 68.43 31.57
+Guyane 62.05 37.95
+Réunion 71.49 28.51
+Sainte Pierre et Miquelon 65.31 34.69
+Saint-Barthelemy et Saint-Martin 40.57 59.43
+Mayotte 49.06 50.94
+Wallis et Futuna 56.06 43.94
+Polynesie Francaise 46.74 53.26
+Nouvelle-Caledonie 36.97 63.03
+Abroad votes 46.95 53.05
@@ -0,0 +1,27 @@
+FR-A Alsace
+FR-B Aquitaine
+FR-C Auvergne
+FR-P Basse-Normandie
+FR-D Bourgogne
+FR-E Bretagne
+FR-F Centre
+FR-G Champagne-Ardenne
+FR-H Corse
+FR-I Franche-Comté
+FR-Q Haute-Normandie
+FR-J Île de France
+FR-K Languedoc-Roussillon
+FR-L Limousin
+FR-M Lorraine
+FR-N Midi-Pyrénées
+FR-O Nord - Pas-de-Calais
+FR-R Pays de la Loire
+FR-S Picardie
+FR-T Poitou-Charentes
+FR-U Provence-Alpes-Côte d'Azur
+FR-V Rhône-Alpes
+FR-GP Gaudeloupe
+FR-GF Guyane
+FR-MQ Martinique
+FR-YT Mayotte
+FR-RE La Réunion
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8"/>
+ <title>Maps</title>
+ <link rel="stylesheet" media="all" href="../jvectormap/jquery-jvectormap.css"/>
+ <script src="../jvectormap/tests/assets/jquery-1.7.2.min.js"></script>
+ <script src="../jvectormap.min.js"></script>
+ <script src="jquery-jvectormap-fr-merc-en.js"></script>
+
+ <script>
+ $(function(){
+ $.getJSON('data.json', function(data){
+ var val = 'year2012',
+ map;
+
+ var map = new jvm.WorldMap({
+ map: 'fr_merc_en',
+ container: $('.map'),
+ series: {
+ regions: [{
+ scale: {
+ '1': '#FF69B4',
+ '2': '#4169E1'
+ },
+ attribute: 'fill',
+ values: data[val].results
+ }]
+ }
+ });
+ });
+ })
+ </script>
+</head>
+<body>
+ <div class="map" style="width: 800px; height: 600px"></div>
+</body>
+</html>

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,38 @@
+# encoding: UTF-8
+
+require 'csv'
+require 'json'
+
+data = {
+ year2012: {
+ candidate1: 'Hollande',
+ candidate2: 'Sarkozy',
+ results: {}
+ },
+ year2007: {
+ candidate1: 'Sarkozy',
+ candidate2: 'Royal',
+ results: {}
+ }
+}
+
+name_to_code = {}
+CSV.foreach('data/fr.tsv', col_sep: "\t", encoding: "UTF-8") do |row|
+ name_to_code[row[1]] = row[0]
+end
+
+CSV.foreach('data/2012.csv', col_sep: "\t", encoding: "UTF-8") do |row|
+ if name_to_code[row[0]]
+ data[:year2012][:results][name_to_code[row[0]]] = row[1] > row[2] ? 1 : 2
+ end
+end
+
+CSV.foreach('data/2007.csv', col_sep: "\t", encoding: "UTF-8") do |row|
+ if name_to_code[row[0]]
+ data[:year2007][:results][name_to_code[row[0]]] = row[1] > row[2] ? 1 : 2
+ end
+end
+
+File.open("data.json", "w") do |file|
+ file.write( data.to_json );
+end

0 comments on commit 85e370a

Please sign in to comment.