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

Mark spots on time series #5

Open
chraibi opened this issue Mar 5, 2024 · 2 comments
Open

Mark spots on time series #5

chraibi opened this issue Mar 5, 2024 · 2 comments
Assignees

Comments

@chraibi
Copy link

chraibi commented Mar 5, 2024

Add the possibility to add flexible numbers of dots on the time series.

@chraibi
Copy link
Author

chraibi commented Mar 7, 2024

try:
    highlight_times = [float(time.strip()) for time in user_input.split(',') if time.strip().isdigit()]
except ValueError:
    st.error("Please enter valid times (numbers only, separated by commas).")
    highlight_times = []

@chraibi
Copy link
Author

chraibi commented Mar 7, 2024

# Session state to keep track of the times list
if 'highlight_times' not in st.session_state:
    st.session_state.highlight_times = []

# Text input for new time addition
new_time = st.text_input("Enter a new time to highlight (seconds):")

# Button to add the new time to the list
if st.button('Add Time'):
    try:
        # Attempt to convert the input to a float and add it to the list
        time_float = float(new_time.strip())
        if time_float not in st.session_state.highlight_times:
            st.session_state.highlight_times.append(time_float)
            st.session_state.highlight_times.sort()  # Keep the list sorted
    except ValueError:
        st.error("Please enter a valid time (a number).")

# Multiselect box for displaying and removing times
selected_times = st.multiselect("Selected times (unselect to remove):",
                                options=st.session_state.highlight_times,
                                default=st.session_state.highlight_times)

# Update the highlight times based on multiselect
st.session_state.highlight_times = selected_times

@chraibi chraibi self-assigned this Mar 19, 2024
chraibi added a commit that referenced this issue Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant