-
Notifications
You must be signed in to change notification settings - Fork 0
/
transforms.js
76 lines (72 loc) · 1.58 KB
/
transforms.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
74
var t = new Array(11).fill(0).map((d, i) => i / 10);
console.log(t)
Plotly.plot('tester', {
data: [{
x: t,
y: t.map(t => t * t + Math.sin(t * 30)),
id: t,
mode: 'lines+markers',
line: {simplify: false},
transforms: [{
type: 'filter',
operation: '<=',
target: t,
value: 0.0
}]
}],
layout: {
xaxis: {autorange: false, range: [0, 1]},
yaxis: {autorange: false, range: [-1, 2]},
updatemenus: [{
type: 'buttons',
xanchor: 'left',
yanchor: 'top',
direction: 'right',
x: 0,
y: 0,
pad: {t: 60},
showactive: false,
buttons: [{
label: 'Play',
method: 'animate',
args: [null, {
transition: {duration: 500},
frame: {duration: 500, redraw: false},
mode: 'immediate',
fromcurrent: true,
}]
}, {
label: 'Pause',
method: 'animate',
args: [[null], {
transition: {duration: 500},
frame: {duration: 500, redraw: false},
mode: 'immediate',
}]
}]
}],
sliders: [{
currentvalue: {
prefix: 't = ',
xanchor: 'right'
},
pad: {l: 130, t: 30},
transition: {
duration: 500,
},
steps: t.map(t => ({
label: t,
method: 'animate',
args: [[t], {
transition: {duration: 500},
frame: {duration: 500, redraw: false},
mode: 'immediate',
}]
}))
}]
},
frames: t.map(t => ({
name: t,
data: [{'transforms[0].value': t}]
}))
})