Skip to content

Commit

Permalink
fixed broken geo maps
Browse files Browse the repository at this point in the history
  • Loading branch information
davelandry committed Jul 8, 2014
1 parent 0bd3874 commit 6c96e29
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 46 deletions.
26 changes: 13 additions & 13 deletions oec/html/explore/embed.html
Original file line number Diff line number Diff line change
Expand Up @@ -667,30 +667,30 @@ <h3>{{ _('Short URL') }}</h3>
break;

case "geo_map":
q = q.defer(d3.json, "/static/json/country_coords.json")

var format_data_orig = format_data
var go = function(){

format_data_orig.apply(this, arguments);
raw_data = arguments[1];
raw_attrs = arguments[2];
raw_coords = arguments[3];

raw_coords["objects"]["TM_WORLD_BORDERS-0.3"]["geometries"].forEach(function(d){
country = raw_attrs.data.filter(function(dd){
return dd.id.substr(2) == d.id.toLowerCase()
})
if (country.length) {
d.id = country[0].id
d.icon = "/static/img/icons/country/country_"+d.id+".png"
}
})

viz
.type("geo_map")
.depth(1)
.color(trade_flow+"_val")
.coords(raw_coords)
.coords("/static/json/country_coords.json",function(raw_coords){
raw_coords["objects"]["TM_WORLD_BORDERS-0.3"]["geometries"].forEach(function(d){
country = raw_attrs.data.filter(function(dd){
return dd.id.substr(2) == d.id.toLowerCase()
})
if (country.length) {
d.id = country[0].id
d.icon = "/static/img/icons/country/country_"+d.id+".png"
}
})
return raw_coords
})
.coords({
"center": [10,0],
"padding": 0,
Expand Down
65 changes: 32 additions & 33 deletions oec/html/profile/country.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,42 +137,41 @@ <h3>{{ b.get_question()|safe }}</h3>
.width(280)
.draw()

d3.json("/static/json/country_coords.json", function(raw_coords){

raw_coords["objects"]["TM_WORLD_BORDERS-0.3"]["geometries"].forEach(function(d){
country = raw_attrs.filter(function(dd){
return dd.id.substr(2) == d.id.toLowerCase()
// instantiate d3plus
var visualization = d3plus.viz()
.attrs(attrs)
.container("#viz")
.coords("/static/json/country_coords.json",function(raw_coords){
raw_coords["objects"]["TM_WORLD_BORDERS-0.3"]["geometries"].forEach(function(d){
country = raw_attrs.filter(function(dd){
return dd.id.substr(2) == d.id.toLowerCase()
})
if (country.length) {
d.id = country[0].id
}
})
if (country.length) {
d.id = country[0].id
}
return raw_coords
})
.coords({
"center": [10,0],
"padding": 0,
"mute": ["anata"]
})
.color("color")
.focus(focus_id)
.height(280)
.messages(true)
.text("name")
.tooltip("value")
.type("geo_map")
.width(280)
.zoom({
"scroll": false,
"pan": false,
"click": false
})
.draw()

// instantiate d3plus
var visualization = d3plus.viz()
.attrs(attrs)
.container("#viz")
.coords({
"value": raw_coords,
"center": [10,0],
"padding": 0,
"mute": ["anata"]
})
.color("color")
.focus(focus_id)
.height(280)
.messages(true)
.text("name")
.tooltip("value")
.type("geo_map")
.width(280)
.zoom({
"scroll": false,
"pan": false,
"click": false
})
.draw()
})
})
</script>
{% endblock %}

0 comments on commit 6c96e29

Please sign in to comment.