Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gr.Plot not firing .change event #9997

Open
1 task done
Josef-Haupt opened this issue Nov 19, 2024 · 0 comments
Open
1 task done

gr.Plot not firing .change event #9997

Josef-Haupt opened this issue Nov 19, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@Josef-Haupt
Copy link

Describe the bug

As I understand the description of the .change event in the docs, if the plot changes from user input or function update, the event should fire, but it currently does not, see my example.

Expected behaviour would, be that the change event fires on blocks.load and lat.change/lon.change as well.

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

import gradio as gr

import plotly.express as px


def plot_map_scatter_mapbox(lat, lon):
    fig = px.scatter_mapbox(
        lat=[lat],
        lon=[lon],
        zoom=3,
        mapbox_style="open-street-map",
    )
    fig.update_layout(margin={"r": 0, "t": 0, "l": 0, "b": 0})
    return fig


def print_lat_lon(lat, lon):
    print(lat, lon)


with gr.Blocks() as blocks:
    map_plot = gr.Plot()

    lat_number = gr.Slider(
        minimum=-90,
        maximum=90,
        value=0,
        step=1,
        label="Latitude",
    )
    lon_number = gr.Slider(
        minimum=-180,
        maximum=180,
        value=0,
        step=1,
        label="Longitude",
    )

    blocks.load(plot_map_scatter_mapbox, inputs=[lat_number, lon_number], outputs=map_plot)
    lat_number.change(plot_map_scatter_mapbox, inputs=[lat_number, lon_number], outputs=map_plot, show_progress=False)
    lon_number.change(plot_map_scatter_mapbox, inputs=[lat_number, lon_number], outputs=map_plot, show_progress=False)
    map_plot.change(print_lat_lon, inputs=[lat_number, lon_number], show_progress=False)


blocks.launch()

Screenshot

No response

Logs

No response

System Info

Gradio: 5.6.0
Win11
Python 3.11.7

Severity

I can work around it

@Josef-Haupt Josef-Haupt added the bug Something isn't working label Nov 19, 2024
@hannahblair hannahblair self-assigned this Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants