FigureWidget error

I have this code and it gives me an error in the FigureWidget "raise NotImplementedError("Cannot “)” I simply have been looking for the solution to this error and I can’t find anything, if you can help I would appreciate it.

import streamlit as st
import plotly.graph_objs as go
import pandas as pd

st.set_page_config(layout="wide")
Csv_uploaded_file = st.file_uploader("Choose a CSV file", type="csv")

if Csv_uploaded_file is not None:
    df = pd.read_csv(Csv_uploaded_file, names=["gx", "gy", "gz", "ax", "ay", "az", "roll", "pitch", "yaw", "time_stamp", "FLAG_VIDEO", "TAG"])
    def find_extremes(trace, points, selector):
        xrange = selector.xrange
        keep_condition = (df['time_stamp'] >= xrange[0]) & (df['time_stamp'] <= xrange[1])
        filtered_df = df[keep_condition]
        st.write(filtered_df)
        st.download_button('Download CSV', filtered_df,'text/csv')

    trace1 = go.Scatter(y=df['ax'], x=df['time_stamp'], mode='lines', name='AccX')
    trace2 = go.Scatter(y=df['az'], x=df['time_stamp'], mode='lines', name='AccZ')
    data = [trace1, trace2]
    fig = go.FigureWidget(data=data)
    scatter = fig.data[0]
    fig.update_layout(
        width=1000,
        height=500,
        xaxis_title='Time_Stamp',
        yaxis_title='Values',
        dragmode="select",
        selectdirection="h",
    )
    scatter.on_selection(find_extremes)
    st.plotly_chart(fig)

Hi @joaoMB1337, welcome to the forum!

Thanks so much for sharing the code you are using. Could you also share the dependencies you are using? I tried this locally and it worked fine, but in another place I saw this error

ImportError: Please install ipywidgets>=7.0.0 to use the FigureWidget class

It seems that you might need to install or update ipywidgets to get this to work.

1 Like

I updated python and all dependencies and it worked perfectly, thanks!