Avoid to rerun certain parts of code

import streamlit as st
from streamlit_timeline import st_timeline

items = [
    {'start': '2023-05-01T00:00', 'end': '2023-05-05T24:00', 'group': 1}
]

groups = [
    {'id': 'ExpandableGroup', 'nestedGroups': ['FurtherExpandableGroup'], 'showNested': True, 'treeLevel': 1}, 
    {'id': 'FurtherExpandableGroup', 'nestedGroups': [1], 'showNested': False, 'treeLevel': 2}, 
    {'id': 1, 'content': '&nbsp &nbsp &nbsp &nbsp &nbspEndLevel ', 'treeLevel': 3}
]

timeline = st_timeline(items=items, groups=groups, height=250)

st.date_input("Choose data")

Having the above code I am creating a timeline using timeline component

On the left side I build certain groups that can be expanded/collapsed by clicking on them. My problem is that if I expand or collapse certain groups with every rerun the timeline will be reset to the default setting. For example if the user selects a new date at the below date picker. This means that all collapsed or expanded groups will loose the state the user has made and will be reset to the default starting state.

Does anybody has an idea how to avoid rerunning the timeline code part but still have the timeline constantly loaded?

Thanks a lot for any help!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.