# Expose plot domain and range

**URL:** <https://community.plotly.com/t/expose-plot-domain-and-range/13050>\
**Category:** Dash Python\
**Created:** [August 26, 2018, 8:17pm UTC](https://community.plotly.com/t/expose-plot-domain-and-range/13050 "2018-08-26T20:17:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ggiesa](https://avatars.discourse-cdn.com/v4/letter/g/839c29/32.png) [@ggiesa](https://community.plotly.com/u/ggiesa)\
**Post date:** [August 26, 2018, 8:17pm UTC](https://community.plotly.com/t/expose-plot-domain-and-range/13050/1 "2018-08-26T20:17:02Z")

</div>

I’d really like access to the domain and range of plots in Dash so I can dynamically update the data displayed when a user zooms or pans around. In my eyes this is a totally fundamental feature, and it’s really frustrating that the only current way to get the information is to implement a Javascript hack (as far as I know).

 ![Screenshot_1](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/e/ee38685433a9c741493b849ad40f66c124330c03.jpeg)

I know this feature has been requested by multiple people over the past couple of years, but I wanted to bring it up again because it appears that there’s still no solution. I love Dash but I feel that this is a major bottleneck for efficient caching, and I’m surprised that there still isn’t a good solution. Am I missing something here?

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [August 26, 2018, 8:57pm UTC](https://community.plotly.com/t/expose-plot-domain-and-range/13050/2 "2018-08-26T20:57:01Z")

</div>

i’m sorry to hear hear at you are frustrated!

this data is actually available in the relayoutData property of the graph. this is the 5th chapter of the dash user guide: [https://dash.plot.ly/interactive-graphing](https://dash.plot.ly/interactive-graphing)

---

<div class="post-metadata">

**Author:** ![ggiesa](https://avatars.discourse-cdn.com/v4/letter/g/839c29/32.png) [@ggiesa](https://community.plotly.com/u/ggiesa)\
**Post date:** [August 27, 2018, 8:47pm UTC](https://community.plotly.com/t/expose-plot-domain-and-range/13050/3 "2018-08-27T20:47:40Z")

</div>

Thanks for the reply, Chris! This should work for what I want to do, but I’m still running into issues with getting the replyoutData callback to work with my candle plot. The behavior seems like a bug to me, but I’m not sure what’s going on so I figured I’d post here before creating an issue. replyoutData works if the plot isn’t being updated by a callback, but otherwise it just returns null. Check out my minimal example below. Am I doing something wrong here?

Here’s what I’m working with:  
**dash\_core\_components ==0.28.0**  
**dash\_html\_components== 0.11.0**  
**dash== 0.26.2**  
**plotly== 3.1.1**

Here’s the code:

```
import pandas as pd
import numpy as np
import json

import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import plotly.graph_objs as go
import plotly

# Data to plot
# ------------------------------------------------------------------------------
candles = pd.DataFrame(np.random.randint(1,100, size = (100,4)),
                       columns = ['open', 'close', 'high', 'low'])

# App
# ------------------------------------------------------------------------------
app = dash.Dash()
serv = app.server

app.layout = \
html.Div([

    # relayoutData doesn't work
    # --------------------------------------------------------------------------
    html.Div([
        html.Button('Reload', id='button1')
    ]),

    html.Div([
        dcc.Graph(
            id='relayout_not_working',
        )
    ]),

    html.Div([
        dcc.Markdown("""
            When Graph is updated by a callback, relayout doesn't work.
        """),
        html.Pre(id='relayout-data1'),
    ], className='three columns'),

    # relayoutData works
    # --------------------------------------------------------------------------
    html.Div([
        dcc.Graph(
            id='relayout_working',
            figure = {
                'data':[
                    go.Candlestick(
                        x = list(candles.index),
                        open = candles.open,
                        high = candles.high,
                        close = candles.close,
                        low = candles.low,
                        name = 'Candles',
                    )
                ],
                'layout':[
                    go.Layout(
                        xaxis = dict(
                            rangeslider = {'visible':False}
                            )
                        )
                ]
                    }
        )
    ]),

    html.Div([
        dcc.Markdown("""
            When plot isn't updated, relayout works fine.
        """),
        html.Pre(id='relayout-data2'),
    ], className='three columns')
])

# Callbacks
#-------------------------------------------------------------------------------
@app.callback(
    dash.dependencies.Output('relayout_not_working', 'figure'),
    [dash.dependencies.Input('button1', 'n_clicks')]
    )
def update_plot(reload):
    figure = {
        'data':[
            go.Candlestick(
                x = list(candles.index),
                open = candles.open,
                high = candles.high,
                close = candles.close,
                low = candles.low,
                name = 'Candles',
            )
        ],
        'layout':[
            go.Layout(
                xaxis = dict(
                    rangeslider = {'visible':False}
                    )
                )
        ]
            }
    return figure

@app.callback(
    Output('relayout-data1', 'children'),
    [Input('relayout_not_working', 'relayoutData')])
def display_selected_data(relayoutData):
    return json.dumps(relayoutData, indent=2)

@app.callback(
    Output('relayout-data2', 'children'),
    [Input('relayout_working', 'relayoutData')])
def display_selected_data(relayoutData):
    return json.dumps(relayoutData, indent=2)

if __name__ == ' __main__':
    app.run_server(debug=True)

```

![Screenshot_2](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/3/382f0a127b2fed3492e4c6e036936b4826f8d478.jpeg)
