-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathflowers.js
47 lines (38 loc) · 1.29 KB
/
flowers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
!function () {
var s = 0.7;
var b = 0.02;
function effectiveness (eng, ee, s, b) {
return (eng - ee) * (1 + (Math.pow(ee, s) * b));
}
function data (eng) {
return _.map(_.range(eng + 1), function (x) {
return { x: x, y: effectiveness(eng, x, s, b) }
});
}
function maxY (data) {
return _.max(data, function (d) { return d.y; });
}
function plotter(label) {
return gg(
{ geometry: 'line', x: 'x', y: 'y', smooth: true, width: 2 },
{
geometry: 'arrow',
x: 'x',
y: 'y',
arrow: { length: 10, width: 3 },
head: function (d) { return maxY(d); },
tail: function (d) { return { x: maxY(d).x, y: 0 }; },
color: '#338',
linewidth: 1,
},
{ aesthetic: 'x', legend: label },
{ aesthetic: 'y', legend: 'Net productivity' }
)
}
var opts = { width: 500, height: 300, padding: 50 };
var commify = d3.format(",d")
_.map([10, 100, 1000, 10000], function (n) {
var label = 'EE Engineers out of ' + commify(n) + ' (s = ' + s + '; b = ' + b + ')';
plotter(label)(data(n), d3.select('#chart' + n), opts);
});
}();