-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserInteraction.js
More file actions
40 lines (35 loc) · 862 Bytes
/
userInteraction.js
File metadata and controls
40 lines (35 loc) · 862 Bytes
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
let someData = {
a: 20,
b: 40,
c: 80
};
d3.select("svg")
.append("rect")
.style("fill", "red")
.attr("x", 210)
.attr("y", 10)
.attr("height", someData.a)
.attr("width", someData.a);
d3.select("select.letterVar")
.on("change", () => update(someData))
.selectAll("option")
.data(Object.keys(someData))
.enter()
.append("option")
.attr("value", d => d)
.text(d => someData[d]);
d3.select("#colorButton").on("change", changeColor);
function update(someData) {
let letterVar = d3.select("select.letterVar").property("value");
console.log(someData[letterVar]);
d3.select("svg")
.selectAll("rect")
.transition()
.duration(1000)
.attr("height", someData[letterVar])
.attr("width", someData[letterVar]);
}
function changeColor() {
let color = $("input[name='colorButton']:active");
console.log(color);
}