Skip to content

Commit 185b9cb

Browse files
committed
Add float arrays to streamlit sample
Signed-off-by: Joe Friedrichsen <[email protected]>
1 parent f142a07 commit 185b9cb

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

examples/sample/sample.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""This example demonstrates how to open/update a Streamlit application using nipanel package."""
22

3+
import itertools
4+
import math
35
import pathlib
46

57
import nipanel
@@ -17,6 +19,11 @@
1719
panel.set_value("sample_float", 3.14)
1820
panel.set_value("sample_bool", True)
1921

22+
x_values = [float(x) for x in itertools.takewhile(lambda p: p < 2*math.pi, itertools.count(0, 0.05))]
23+
y_values = [math.sin(x) for x in x_values]
24+
panel.set_value("x_values", x_values)
25+
panel.set_value("y_values", y_values)
26+
2027
input("Press Enter to close the panel...")
2128

2229
panel.close_panel(reset=True)

examples/sample/sample_panel.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Streamlit application script for displaying values using nipanel package."""
22

3+
import pandas as pd
34
import streamlit as st
45

56
import nipanel
@@ -15,9 +16,22 @@
1516
st.write("Integer")
1617
st.write("Float")
1718
st.write("Boolean")
19+
st.write("Line")
1820

1921
with col2:
2022
st.write(panel.get_value("sample_string"))
2123
st.write(panel.get_value("sample_int"))
2224
st.write(panel.get_value("sample_float"))
2325
st.write(panel.get_value("sample_bool"))
26+
st.line_chart(
27+
data = pd.DataFrame(
28+
{
29+
"x": panel.get_value("x_values"),
30+
"y": panel.get_value("y_values"),
31+
}
32+
),
33+
x="x",
34+
y="y",
35+
x_label="x",
36+
y_label="sin(x)",
37+
)

0 commit comments

Comments
 (0)