Permalink
Browse files

Adding legends

  • Loading branch information...
1 parent 39904bc commit 62316ac5030550c45d7a6c8d3e8e66f5c405dd68 @madewulf committed Oct 2, 2012
Showing with 26 additions and 9 deletions.
  1. +8 −4 app.py
  2. +13 −0 static/js/pyramid.js
  3. +5 −5 templates/index.html
View
12 app.py
@@ -4,8 +4,11 @@
import logging, sys
import os
-from werkzeug.contrib.cache import MemcachedCache
-cache = MemcachedCache(['127.0.0.1:11211'])
+#from werkzeug.contrib.cache import MemcachedCache
+#cache = MemcachedCache(['127.0.0.1:11211'])
+
+from werkzeug.contrib.cache import SimpleCache
+cache = SimpleCache()
logging.basicConfig(stream=sys.stderr)
@@ -17,7 +20,7 @@
@app.route('/<country>/<int:year>/')
@app.route('/<country>/<int:year>/<currentLetter>/')
def pyramid(country="WORLD",year="2010",currentLetter=None):
- cache_key = "%s%s" % (country, year)
+ cache_key = "%s%s%s" % (country, year, ""+request.path=="/")
cached_value = cache.get(cache_key)
if cached_value is not None :
app.logger.debug("returning cached value")
@@ -63,7 +66,8 @@ def pyramid(country="WORLD",year="2010",currentLetter=None):
currentLetter = currentLetter,
years = years,
alphabet = alphabet,
- countries_lists = countries_lists
+ countries_lists = countries_lists,
+ home = request.path== '/'
)
cache.set(cache_key,res)
app.logger.debug("setting cached value")
View
13 static/js/pyramid.js
@@ -125,6 +125,12 @@ function drawPyramidCanvas() {
text = paper.text(x2, canvas_size - 10, (i * 2.5) + "%");
text.attr({fill:'#fff',font: '10px Helvetica, Arial'});
}
+
+ var text = paper.text( canvas_size/4, canvas_size/6,"Male");
+ text.attr({fill:'#fff','font': '65px LeagueGothic, Helvetica, Arial'});
+
+ var text = paper.text( canvas_size*3/4, canvas_size/6,"Female");
+ text.attr({fill:'#fff','font': '65px LeagueGothic, Helvetica, Arial'});
}
@@ -377,6 +383,13 @@ function drawPopGraphCanvas()
axesPath += "M "+ 0 + " " + (2*curvePadding +1) + "L" +curvePadding + ' ' + (curvePadding + 1) ;
axesPath += "M "+ 2*curvePadding + " " + (2*curvePadding +1) + "L" + curvePadding+ ' ' + (curvePadding + 1) ;
+ /* a label */
+ var t = paper2.text(curvePadding +45 ,curvePadding +5,"Population Size");
+ t.attr({'font': '10px Helvetica, Arial',fill:'#07669d'});
+ /*another label */
+ t = paper2.text(useableWidth-5 ,useableHeight- 5,"Year");
+ t.attr({'font': '10px Helvetica, Arial',fill:'#07669d'});
+
axes = paper2.path(axesPath);
axes.attr({stroke:'#07669d', 'stroke-width':1});
View
10 templates/index.html
@@ -2,9 +2,11 @@
<html>
<head>
<meta charset="utf-8"/>
-
+{% if home %}
+ <title>Population Pyramids of the Whole World from 1950 to 2100 &mdash; PopulationPyramid.net</title>
+{% else %}
<title>Population Pyramid of {{currentCountryName}} in {{currentYear}} &mdash; PopulationPyramid.net</title>
-
+{% endif %}
<!-- facebook open graphs tags-->
<meta http-equiv="X-UA-Compatible" content="IE=Edge;chrome=1">
<meta property="og:title" content="PopulationPyramid.net"/>
@@ -73,9 +75,7 @@ <h1 style="padding:0 0 0 0px;text-shadow: 0px -1px 0 #3796CA;width:400px;">Popul
scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:20px;"
allowTransparency="true"></iframe>
</div>
- <p style="float:right; margin-top:-17px; margin-right:10px; color:#66A7CC; font-size:0.8em;">Soon on iPad as
- part of the <a href="http://movingworldapp.com" style="color:#66A7CC;text-decoration: underline; ">Moving
- World App</a></p>
+ <p style="float:right; margin-top:-17px; margin-right:10px; color:#66A7CC; font-size:0.8em;"><a href="http://en.wikipedia.org/wiki/Population_pyramid" style="color:#66A7CC;text-decoration: underline; ">What is a population pyramid?</a></p>
</div>
</div>

0 comments on commit 62316ac

Please sign in to comment.