Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Range from yaxis after ZoomOut (DoubleClick) not the preset

$
0
0

Hello, the range after zoom out is unfortunately no longer the previously set. Where is the error in my script? Or do I have to add something in the code?

df_temp = pd.read_csv('temp_01.csv', sep=';', decimal=',')
df_temp['Datum'] = pd.to_datetime(df_temp['Datum'])

data = {'Temperatur': ['Min', 'Max', 'Avg'],
        'Value': [10, 11, 12]}

df_data = pd.DataFrame(data)

# print(df_temp.dtypes)

app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])

card_main = dbc.Card(
    [
        dbc.CardImg(src="/assets/123.svg", top=True, bottom=False,
                    title="123", alt='Image crashed'),
        dbc.CardBody(
            [
                html.H4("Wetterturm", className="card-title"),
                html.H6("Temperatur", className="card-subtitle"),
                html.P("Wähle den Tag für die Anzeige im Diagramm aus!", className="card-text"),
                dcc.Dropdown(id='user_choice', options=[{'label': day, "value": day} for day in df_temp.day.unique()],
                             value=17, clearable=False, style={"color": "#000000"}),
            ]
        ),
    ],
    color="#009474",   # https://bootswatch.com/default/ for more card colors
    inverse=False,   # change color of text (black or white)
    outline=False,  # True = remove the block colors from the background and header
)

card_table = dbc.Card(
    [
        dt.DataTable(id='data-table',
                     columns=[{"name": i, "id": i} for i in df_data.columns],
                     data=df_data.to_dict('records')
                     )]
)


card_graph = dbc.Card(
        dcc.Graph(id='graph', figure={}), body=False, color="secondary",
)

app.layout = html.Div([
    dbc.Row([dbc.Col(card_main, width=3),
             dbc.Col(card_table, width=3),
             dbc.Col(card_graph, width=5)], justify="around"),  # justify="start", "center", "end", "between", "around"

])


@app.callback(
    Output("graph", "figure"),
    [Input("user_choice", "value")]
)
def update_graph(value):

    graph_plot = make_subplots(specs=[[{'secondary_y': True}]])

    graph_plot.add_trace(
        go.Scatter(x=df_temp.query("day=={}".format(str(value)))['Datum'],
                   y=df_temp.query("day=={}".format(str(value)))['Aussenlufttemperatur'],
                   name='Außenlufttemperatur'),
        secondary_y=False,
    )

    graph_plot.add_trace(
        go.Scatter(x=df_temp.query("day=={}".format(str(value)))['Datum'],
                   y=df_temp.query("day=={}".format(str(value)))['Luftfeuchte'],
                   name='Luftfeuchte'),
        secondary_y=True,
    )
    graph_plot.update_yaxes(secondary_y=True, dtick=20, range=[0, 100])
    graph_plot.update_yaxes(secondary_y=False, dtick=5, range=[0, 50])
    graph_plot.update_xaxes(dtick=14400000)  # dtick in ms
    go.config = {'doubleClick': 'reset'}
    return graph_plot


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


Left before Zoom Out, Right after

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 6271

Latest Images

Trending Articles



Latest Images