diff --git a/bt/views.py b/bt/views.py index e8c6fb98f9883e3404951bf888a884f26ee5a630..e4f8368b292fcf8634d6a34ceb5615cbfea35d2a 100644 --- a/bt/views.py +++ b/bt/views.py @@ -226,8 +226,13 @@ def filter_violations(request, country, operator=None): violations = Violation.objects.filter(activationid='', country=country, operator=operator) if not request.GET.get('all'): violations = violations.exclude(state__in=['duplicate', 'closed']) + countries=sorted([(i['total'],i['country']) + for i in Violation.objects.values('country').filter(activationid='',country=country).exclude(state__in=['duplicate', 'closed']).annotate(total=Count('country'))], + reverse=True) + countryweights=json.dumps([{'iso2': y, 'w': x} for x, y in countries]) return render_to_response('list.html', { "violations": violations, + "country": country, "status": STATUS }, context_instance=RequestContext(request)) diff --git a/media/js/map.js b/media/js/map.js index e5be772a3e615a86a2158d9b76ce78cad42d2f04..b6bc7a5142174da3d8dfbd5bdb6fa80be0970089 100644 --- a/media/js/map.js +++ b/media/js/map.js @@ -6,20 +6,52 @@ $script.ready('kartograph', function() { window.map = $K.map('#map'); map.loadMap('/site_media/eu.svg', function(map) { map - .addLayer('eu', 'bgback') - .addLayer('eu', 'bg') - .addLayer('eu', 'bgstroke') + .addLayer({'id': 'eu', + 'className': 'bgback', + filter: function(d) { + if(country.length==2) { + return d.iso2 == country; + } + return true; + } + }) + .addLayer({'id': 'eu', + 'className': 'bg', + filter: function(d) { + if(country.length==2) { + return d.iso2 == country; + } + return true; + } + }) + .addLayer({'id': 'eu', + 'className': 'bgstroke', + filter: function(d) { + if(country.length==2) { + return d.iso2 == country; + } + return true; + } + }) .addLayer({'id': 'countries', 'className': 'context'}) .addLayer('graticule') .addLayer({'id': 'eu', 'className': 'fg', + filter: function(d) { + if(country.length==2) { + return d.iso2 == country; + } + return true; + }, 'tooltip': { content: function(obj,foo) { var count=0; - for(var i=0;i0) { @@ -45,16 +77,18 @@ $script.ready('kartograph', function() { limits: chroma.limits(data, 'q', 6, 'w') }); - map.choropleth({ - data: data, - layer: 'fg', - key: 'iso2', - colors: function(d) { - if (d == null) return '#fff'; - return colorscale.getColor(d['w']); - }, - duration: 0 - }); + if(data) { + map.choropleth({ + data: data, + layer: 'fg', + key: 'iso2', + colors: function(d) { + if (d == null) return '#fff'; + return colorscale.getColor(d['w']); + }, + duration: 0 + }); + } }); }); }); diff --git a/templates/list.html b/templates/list.html index 58b751fe02c85b9cac5e65c33f5253d183d1770a..4aaa7a720b76c6d3ae31e1f94ec4df21a6a5d103 100644 --- a/templates/list.html +++ b/templates/list.html @@ -18,9 +18,8 @@ $script(['{{ MEDIA_URL }}/js/raphael.min.js', '{{ MEDIA_URL }}/js/kartograph.min.js', '{{ MEDIA_URL }}/js/chroma.min.js', '{{ MEDIA_URL }}/js/qtip.min.js'], 'kartograph');