Commit 909f0db0 authored by S Anand's avatar S Anand

BUG: G.map().dorling() should not re-compute size. Re-use computed size

This causes a problem when random numbers are used for sizes. The second
time the function is called, the values are different.
parent d8aaffb6
......@@ -46,12 +46,11 @@ G.map = function() {
self.dorling = function(selection) {
center_shape()
var circle_path = function(d, i) {
var r = size(d, i)
return r > 0 ? 'M0,0m-{r},0a{r},{r} 0 1,0 {d},0a{r},{r} 0 1,0 -{d},0'
.replace(/\{r\}/g, r)
.replace(/\{d\}/g, 2 * r)
: 'M0,0'
var circle_path = function(d) {
return d.r > 0 ? 'M0,0m-{r},0a{r},{r} 0 1,0 {d},0a{r},{r} 0 1,0 -{d},0'
.replace(/\{r\}/g, d.r)
.replace(/\{d\}/g, 2 * d.r)
: 'M0,0'
},
nodes = shape.features.map(function(d, i) {
var centroid = path.centroid(d.geometry)
......@@ -68,11 +67,9 @@ G.map = function() {
// Don't transition dorling, for now. Change in values look weird
// .transition()
.attr('d', circle_path)
.attr('transform', function(d, i) { return 'scale(' + size(d, i) + ')' })
update.enter()
.append('path')
.attr('class', 'map')
.attr('transform', function(d, i) { return 'scale(' + size(d, i) + ')' })
.attr('d', circle_path)
update.exit()
.remove()
......
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