Skip to content

Commit 28f2209

Browse files
author
Dilmi Wickramanayake
committed
simple graph changes
1 parent 886623e commit 28f2209

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

examples/simple_graph/simple_graph.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Example of using nipanel to display a sine wave graph using st_echarts."""
2+
23
import math
34
import time
45
from pathlib import Path
@@ -14,6 +15,7 @@
1415
amplitude = 1.0
1516
frequency = 1.0
1617
num_points = 100
18+
1719
try:
1820
print(f"Panel URL: {panel.panel_url}")
1921
print("Press Ctrl+C to exit")
@@ -31,5 +33,7 @@
3133
# Slowly vary the frequency for a more dynamic visualization
3234
frequency = 1.0 + 0.5 * math.sin(time.time() / 5.0)
3335
time.sleep(0.1)
36+
3437
except KeyboardInterrupt:
35-
print("Exiting...")
38+
print("Exiting...")
39+

examples/simple_graph/simple_graph_panel.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""A Streamlit visualization panel for the simple_graph.py example script."""
2+
23
import streamlit as st
34
from streamlit_echarts import st_echarts
45

@@ -13,6 +14,7 @@
1314
sine_values = panel.get_value("sine_values", [0.0])
1415
amplitude = panel.get_value("amplitude", 1.0)
1516
frequency = panel.get_value("frequency", 1.0)
17+
1618
col1, col2, col3, col4, col5 = st.columns(5)
1719
with col1:
1820
st.metric("Amplitude", f"{amplitude:.2f}")
@@ -27,6 +29,7 @@
2729

2830
# Prepare data for echarts
2931
data = [{"value": [x, y]} for x, y in zip(time_points, sine_values)]
32+
3033
# Configure the chart options
3134
options = {
3235
"animation": False, # Disable animation for smoother updates
@@ -51,5 +54,6 @@
5154
}
5255
],
5356
}
57+
5458
# Display the chart
55-
st_echarts(options=options, height="400px", key="graph")
59+
st_echarts(options=options, height="400px", key="graph")

0 commit comments

Comments
 (0)