Skip to content

Commit 8e8a296

Browse files
committed
add disabling button example
1 parent 261c2ed commit 8e8a296

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
name: Disabling Buttons for Specific Axes
3+
language: plotly_js
4+
suite: configuration
5+
order: 5.8
6+
sitemap: false
7+
arrangement: horizontal
8+
markdown_content: |
9+
*New in 3.1*
10+
11+
Disabling the zoom in, zoom out, and autoscale buttons for specific axes is supported on cartesian axes using the `modebardisable` attribute. In the following example, the zoom in and zoom out buttons are disabled on the `xaxis`, meaning these buttons only zoom in and out on the `yaxis`. Disable the autoscale button using `modebardisable='autoscale'`. You can also disable both autoscaling and zoom buttons using `modebardisable='zoominout+autoscale'`.
12+
---
13+
var data = [{
14+
type: "scatter",
15+
mode: "lines+markers",
16+
x: ["2023-01-01", "2023-02-01", "2023-03-01", "2023-04-01", "2023-05-01", "2023-06-01"],
17+
y: [150, 160, 155, 170, 165, 180],
18+
name: "Google Stock Price"
19+
}];
20+
21+
var layout = {
22+
title: "Google Stock Price Over Time with Mode Bar Disabled",
23+
xaxis: {
24+
title: "Date",
25+
type: "date",
26+
// Try zooming in or out using the modebar buttons. These only apply to the yaxis in this example.
27+
modebardisable: "zoominout"
28+
},
29+
yaxis: {
30+
title: "Stock Price (USD)"
31+
}
32+
};
33+
34+
Plotly.newPlot("myDiv", data, layout);

0 commit comments

Comments
 (0)