Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fabd9ba

Browse files
committed
added dropdown update menu example in js and python
1 parent bf69c25 commit fabd9ba

File tree

2 files changed

+120
-0
lines changed

2 files changed

+120
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
name: Dropdown events to update menus in Plotly.js charts
3+
plot_url: https://codepen.io/etpinard/embed/pbxkNb/?height=558&theme-id=15263&default-tab=result
4+
language: plotly_js
5+
suite: dropdowns-events
6+
sitemap: false
7+
order: 0
8+
arrangement: horizontal
9+
---
10+
function makeTrace(i) {
11+
return {
12+
y: Array.apply(null, Array(10)).map(() => Math.random()),
13+
line: {
14+
shape: 'spline' ,
15+
color: 'red'
16+
},
17+
visible: i === 0,
18+
name: 'Data set ' + i,
19+
};
20+
}
21+
22+
Plotly.plot('graph', [0, 1, 2, 3].map(makeTrace), {
23+
updatemenus: [{
24+
y: 0.8,
25+
yanchor: 'top',
26+
buttons: [{
27+
method: 'restyle',
28+
args: ['line.color', 'red'],
29+
label: 'red'
30+
}, {
31+
method: 'restyle',
32+
args: ['line.color', 'blue'],
33+
label: 'blue'
34+
}, {
35+
method: 'restyle',
36+
args: ['line.color', 'green'],
37+
label: 'green'
38+
}]
39+
}, {
40+
y: 1,
41+
yanchor: 'top',
42+
buttons: [{
43+
method: 'restyle',
44+
args: ['visible', [true, false, false, false]],
45+
label: 'Data set 0'
46+
}, {
47+
method: 'restyle',
48+
args: ['visible', [false, true, false, false]],
49+
label: 'Data set 1'
50+
}, {
51+
method: 'restyle',
52+
args: ['visible', [false, false, true, false]],
53+
label: 'Data set 2'
54+
}, {
55+
method: 'restyle',
56+
args: ['visible', [false, false, false, true]],
57+
label: 'Data set 3'
58+
}]
59+
}],
60+
});
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
name: Dropdown Events to update menus
3+
plot_url: https://codepen.io/etpinard/embed/pbxkNb/?height=725&theme-id=15263&default-tab=result
4+
language: python
5+
suite: dropdown-events
6+
arrangement: horizontal
7+
sitemap: false
8+
order: 1
9+
---
10+
function makeTrace(i) {
11+
return {
12+
y: Array.apply(null, Array(10)).map(() => Math.random()),
13+
line: {
14+
shape: 'spline' ,
15+
color: 'red'
16+
},
17+
visible: i === 0,
18+
name: 'Data set ' + i,
19+
};
20+
}
21+
22+
Plotly.plot('graph', [0, 1, 2, 3].map(makeTrace), {
23+
updatemenus: [{
24+
y: 0.8,
25+
yanchor: 'top',
26+
buttons: [{
27+
method: 'restyle',
28+
args: ['line.color', 'red'],
29+
label: 'red'
30+
}, {
31+
method: 'restyle',
32+
args: ['line.color', 'blue'],
33+
label: 'blue'
34+
}, {
35+
method: 'restyle',
36+
args: ['line.color', 'green'],
37+
label: 'green'
38+
}]
39+
}, {
40+
y: 1,
41+
yanchor: 'top',
42+
buttons: [{
43+
method: 'restyle',
44+
args: ['visible', [true, false, false, false]],
45+
label: 'Data set 0'
46+
}, {
47+
method: 'restyle',
48+
args: ['visible', [false, true, false, false]],
49+
label: 'Data set 1'
50+
}, {
51+
method: 'restyle',
52+
args: ['visible', [false, false, true, false]],
53+
label: 'Data set 2'
54+
}, {
55+
method: 'restyle',
56+
args: ['visible', [false, false, false, true]],
57+
label: 'Data set 3'
58+
}]
59+
}],
60+
});

0 commit comments

Comments
 (0)