Commit 6d5958a6 authored by stef's avatar stef
Browse files

[enh] added legend to map on view

parent af1e9241
...@@ -214,13 +214,16 @@ def list_violations(request): ...@@ -214,13 +214,16 @@ def list_violations(request):
countries=sorted([(i['total'],i['country']) countries=sorted([(i['total'],i['country'])
for i in Violation.objects.values('country').filter(activationid='').annotate(total=Count('country'))], for i in Violation.objects.values('country').filter(activationid='').annotate(total=Count('country'))],
reverse=True) reverse=True)
countries=json.dumps(dict([(c.lower(),"#ff%x00" % (3*int(64*(float(w)/countries[0][0]))+63)) for w,c in countries])) legend=sorted(set([(w, "rgba(255,%d, 00, 0.4)" % (w*768/(countries[0][0]+1)%256)) for w,c in countries]),reverse=True)
countrycolors=json.dumps(dict([(c.lower(),"#ff%02x00" % (w*768/(countries[0][0]+1)%256)) for w,c in countries]))
#confirms=sorted([(i['total'],i['country']) #confirms=sorted([(i['total'],i['country'])
# for i in Violation.objects.values('country').filter(activationid='').annotate(total=Count('confirmation'))], # for i in Violation.objects.values('country').filter(activationid='').annotate(total=Count('confirmation'))],
# reverse=True) # reverse=True)
return render_to_response('list.html', return render_to_response('list.html',
{"violations": violations, {"violations": violations,
"countries": countries,}, "countries": dict([(y,x) for x,y in countries]),
"countrycolors": countrycolors,
"legend": legend,},
#"confirms": confirms,}, #"confirms": confirms,},
context_instance=RequestContext(request)) context_instance=RequestContext(request))
......
...@@ -625,4 +625,7 @@ ul.messages { ...@@ -625,4 +625,7 @@ ul.messages {
#similar_cases li { list-style: disc inside; margin-left: 0.3em; color: black; } #similar_cases li { list-style: disc inside; margin-left: 0.3em; color: black; }
.mceToolbar { display:none; } .mceToolbar { display:none; }
\ No newline at end of file #legend { text-align: center; margin-bottom: .5em; font-size: .7em; }
#legend li { padding: .1em; display: inline; }
#map { float: right; }
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment