gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
33.47k stars 2.53k forks source link

gr.lineplot error with dynamic rendering #9608

Open tyc333 opened 2 weeks ago

tyc333 commented 2 weeks ago

Describe the bug

gr.lineplot (maybe besides other plots) do work with gr.render, but then report error "Uncaught (in promise) TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'", and the components on the page become no response.

Have you searched existing issues? 🔎

Reproduction

import pandas as pd
from random import randint, random
import gradio as gr

with gr.Blocks() as line_plots:
    button = gr.Button("Generate Data")
    @gr.render(button, triggers=[button.click])
    def generate_data(button):
        temp_sensor_data = pd.DataFrame(
            {
                "time": pd.date_range("2021-01-01", end="2021-01-05", periods=100),
                "temperature": [randint(50 + 10 * (i % 2), 65 + 15 * (i % 2)) for i in range(100)],
                "humidity": [randint(50 + 10 * (i % 2), 65 + 15 * (i % 2)) for i in range(100)],
                "location": ["indoor", "outdoor"] * 50,
            }
        )
        temp_by_time = gr.LinePlot(
        temp_sensor_data,
        x="time",
        y="temperature",
    )
        # gr.Textbox(str(temp_sensor_data))

if __name__ == "__main__":
    line_plots.launch()

Screenshot

image click the button and no response after the first time.

Logs

"Uncaught (in promise) TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'

System Info

gradio == 4.44.1

Severity

I can work around it

isatyamks commented 2 weeks ago

@tyc333 kindly review my pr https://github.com/gradio-app/gradio/pull/9627