-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotsliders.js
39 lines (30 loc) · 1021 Bytes
/
plotsliders.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
var makeslider = function() {
var etfcontrol = d3.select("div#shareslider")
.selectAll("div")
.data(d3.entries(purchased))
.enter()
.append("div")
.attr("id", function(d) {return d.key;});
etfcontrol.append("label")
.text(function(d) {return d.key;});
etfcontrol.append("input")
.attr("type", "button")
.property("value", "<")
.on("click", function(d) { etfchanged(d, -1); });
etfcontrol.append("span")
.text(function(d) {return d.value;})
.attr("id", function(d) {return d.key;});
etfcontrol.append("input")
.attr("type", "button")
.property("value", ">")
.on("click", function(d) { etfchanged(d, 1); });
}
function etfchanged(d, incre) {
purchased[d.key] += incre;
if(purchased[d.key] < 0)
purchased[d.key] = 0;
d3.selectAll("span")
.data(d3.entries(purchased))
.text(function(d) {return d.value;});
updatetable(pricedata, metric);
}