-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogistic0.js
73 lines (55 loc) · 1.65 KB
/
logistic0.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// parte dello slider
var sliderR0 = document.getElementById("r0");
var displayR0 = document.getElementById("displayR0");
var len=70;
r=sliderR0.value;
displayR0.innerHTML="r = "+r;
data0=curve(r);
// append the svg object to the body of the page
var g0 = d3.select("#curve0")
.append("g")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.attr("transform","translate(" + margin.left + "," + margin.top + ")");
var x0 = d3.scaleLinear()
.domain([0,1])
.range([ 0, width ]);
// Add Y axis
var y0 = d3.scaleLinear()
.domain([0,1])
.range([height, 0]);
const line0=d3.line()
.x(function(d){return x0(d.x);})
.y(function(d){return y0(d.y);})
// Add the line
g0.append("path")
.data([data0])
.attr("d",line0)
.attr("id","curve")
.style("fill",'none')
.style("stroke",'#ff7300')
.style("stroke-width","3px");
/*
vecchia versione del codice, funzionava solo con firefox.
Però era bella perchè aveva le cose formattate per benino
const syncR0 = function(){
r = this.value;
console.log(r);
g0.select("#curve").data([curve(r)]).attr("d", line0);
displayR0.innerHTML="\\(r = "+r+"\\)";
MathJax.typesetPromise([displayR0]);//slow
}
*/
const syncR0 = function(){
r = this.value;
g0.select("#curve").data([curve(r)]).attr("d", line0);
displayR0.innerHTML="r = "+r;
}
sliderR0.addEventListener("input", syncR0)
g0.append("g")
.attr("id","xaxis0")
.attr("transform", "translate(0," + height + ")")
.call(d3.axisBottom(x0));
g0.append("g")
.attr("transform", "translate(0,0)")
.call(d3.axisLeft(y0));