Hi @am1234 yes, in Dash you can use a clientside callback to grab the axis ranges:
import dash
from dash import html, dcc, clientside_callback, Output, Input, State
import plotly.graph_objects as go
app = dash.Dash(__name__)
app.layout = html.Div(
[
html.Button(id='btn', children='get range'),
dcc.Graph(
id='graph',
figure=go.Figure(
go.Scatter(
x=[*range(100)],
y=[*range(100)]
)
)
),
html.Pre(id='out')
]
)
clientside_callback(
"""
function(click, fig) {
const x_range = fig.layout.xaxis.range;
const y_range = fig.layout.yaxis.range;
return JSON.stringify([x_range, y_range])
}
""",
Output('out', 'children'),
Input('btn', 'n_clicks'),
State('graph', 'figure'),
prevent_initial_call=True
)
if __name__ == "__main__":
app.run(debug=True)
mred cscb range