-
Notifications
You must be signed in to change notification settings - Fork 3
/
streamlit_app.py
105 lines (95 loc) · 2.84 KB
/
streamlit_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import streamlit as st
from streamlit_timeline import st_timeline
st.set_page_config(page_title="Timeline", layout="wide")
st.title("Streamlit Timeline")
st.markdown(
"""
Streamlit component for rendering [vis.js timeline](https://github.com/visjs/vis-timeline).
Check out the GitHub repositories [streamlit-timeline](https://github.com/giswqs/streamlit-timeline) and
[streamlit-timeline-demo](https://github.com/giswqs/streamlit-timeline-demo). For JavaScript examples,
check out the vis.js timeline [examples](https://visjs.github.io/vis-timeline/examples/timeline/) and
[documentation](https://visjs.github.io/vis-timeline/docs/timeline/).
"""
)
st.header("Basic Example")
items = [
{"id": 1, "content": "2022-10-20", "start": "2022-10-20"},
{"id": 2, "content": "2022-10-09", "start": "2022-10-09"},
{"id": 3, "content": "2022-10-18", "start": "2022-10-18"},
{"id": 4, "content": "2022-10-16", "start": "2022-10-16"},
{"id": 5, "content": "2022-10-25", "start": "2022-10-25"},
{"id": 6, "content": "2022-10-27", "start": "2022-10-27"},
]
timeline = st_timeline(items, groups=[], options={}, height="300px")
st.subheader("Selected item")
st.write(timeline)
st.header("With groups")
items = [
{
"id": 1,
"content": "editable",
"editable": True,
"start": "2022-08-23",
"group": 1,
},
{
"id": 2,
"content": "editable",
"editable": True,
"start": "2022-08-23T23:00:00",
"group": 2,
},
{
"id": 3,
"content": "Read-only",
"editable": False,
"start": "2022-08-24T16:00:00",
"group": 1,
},
{
"id": 4,
"content": "Read-only",
"editable": False,
"start": "2022-08-26",
"end": "2022-09-02",
"group": 2,
},
{
"id": 5,
"content": "editable",
"editable": True,
"start": "2022-08-28",
"group": 1,
},
{
"id": 6,
"content": "Read-only",
"editable": False,
"start": "2022-08-29",
"group": 2,
},
{
"id": 7,
"content": "editable",
"editable": True,
"start": "2022-08-31",
"end": "2022-09-03",
"group": 1,
},
{
"id": 8,
"content": "Read-only",
"editable": False,
"start": "2022-09-04T12:00:00",
"group": 2,
},
{"id": 9, "content": "Default", "start": "2022-09-04", "group": 1},
{"id": 10, "content": "Default", "start": "2022-08-24", "group": 2},
]
groups = [
{"id": 1, "content": "group 1", "style": "color: black; background-color: cyan;"},
{"id": 2, "content": "group 2", "style": "color: black; background-color: pink;"},
]
timeline = st_timeline(items, groups=groups, options={}, height="300px")
st.subheader("Selected item")
st.write(timeline)