Skip to content

Commit

Permalink
Merge branch 'master' of github.com:E2D3/e2d3-contrib
Browse files Browse the repository at this point in the history
  • Loading branch information
chimerast committed Feb 19, 2015
2 parents 8ccd4ce + 1a2d005 commit 5eba9f5
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions japanmap-javascript/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ define(['d3', 'topojson'], function (d3, topojson) {
var path = d3.geo.path()
.projection(projection);

svg.append('g')
.attr('id', 'legend_group');

d3.json(baseUrl + '/japan.topojson', function (error, json) {
svg.selectAll('.states')
.data(topojson.feature(json, json.objects.japan).features)
Expand Down Expand Up @@ -76,6 +79,28 @@ define(['d3', 'topojson'], function (d3, topojson) {
return '#ffffff';
}
});

var legend_data = color.ticks(5).reverse();
d3.select(node).select('#legend_group')
.selectAll('.legend_rect')
.data(legend_data)
.enter()
.append('rect')
.attr('class', 'legend_rect')
.attr('x', 0)
.attr('y', function(value, i){return i*20})
.attr('width', '15')
.attr('height', '15')
.attr('fill', function(value){return color(value)})
d3.select(node).select('#legend_group')
.selectAll('.legend_text')
.data(legend_data)
.enter()
.append('text')
.attr('class', 'legend_text')
.attr('x', 20)
.attr('y', function(value, i){return i*20+10})
.text(function(value){return value})
},
/**
* (Optional) called on window resized.
Expand Down

0 comments on commit 5eba9f5

Please sign in to comment.