Browse Source

Update bubble extension

pull/1177/merge
Masayuki Tanaka 10 years ago
parent
commit
b1a4e741b2
  1. 9
      extensions/chart-bubble/bubble.js

9
extensions/chart-bubble/bubble.js

@ -41,8 +41,7 @@
var names = extra.names, values = extra.values, base_length = extra.base_length, var names = extra.names, values = extra.values, base_length = extra.base_length,
x = names[d.x], y = d.id, x = names[d.x], y = d.id,
key = extra.getKey(x, y), value = !values[key] ? 0 : values[key], key = extra.getKey(x, y), value = !values[key] ? 0 : values[key],
max, max_r, max_area, min, min_r, min_area, max, max_r, max_area, a, area, r;
a, area, r;
if (!base_length) { if (!base_length) {
base_length = extra.base_length = d3.min([ base_length = extra.base_length = d3.min([
@ -52,14 +51,10 @@
} }
max = d3.max(Object.keys(values).map(function (key) { return values[key]; })); max = d3.max(Object.keys(values).map(function (key) { return values[key]; }));
min = d3.min(Object.keys(values).map(function (key) { return values[key]; }));
max_r = (base_length / (names.length * 2)); max_r = (base_length / (names.length * 2));
max_area = max_r * max_r * Math.PI; max_area = max_r * max_r * Math.PI;
min_r = Math.sqrt(min * max_r * max_r / max);
min_area = min_r * min_r * Math.PI;
a = (max_area - min_area) / (max - min); a = max_area / max;
area = value * a; area = value * a;
r = Math.sqrt(area / Math.PI); r = Math.sqrt(area / Math.PI);

Loading…
Cancel
Save