Skip to content

Commit 2a0c4e4

Browse files
Mike ProsserMike Prosser
authored andcommitted
revert simple_graph changes
1 parent 0cbbee4 commit 2a0c4e4

File tree

3 files changed

+14
-29
lines changed

3 files changed

+14
-29
lines changed

examples/simple_graph/amplitude_enum.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/simple_graph/simple_graph.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
from pathlib import Path
66

77
import numpy as np
8-
from amplitude_enum import AmplitudeEnum
98

109
import nipanel
1110

1211

1312
panel_script_path = Path(__file__).with_name("simple_graph_panel.py")
1413
panel = nipanel.create_panel(panel_script_path)
1514

15+
amplitude = 1.0
16+
frequency = 1.0
1617
num_points = 100
1718

1819
try:
@@ -21,19 +22,16 @@
2122

2223
# Generate and update the sine wave data periodically
2324
while True:
24-
amplitude = panel.get_value("amplitude", AmplitudeEnum.SMALL)
25-
base_frequency = panel.get_value("base_frequency", 1.0)
26-
27-
# Slowly vary the total frequency for a more dynamic visualization
28-
frequency = base_frequency + 0.5 * math.sin(time.time() / 5.0)
29-
3025
time_points = np.linspace(0, num_points, num_points)
31-
sine_values = amplitude.value * np.sin(frequency * time_points)
26+
sine_values = amplitude * np.sin(frequency * time_points)
3227

33-
panel.set_value("frequency", frequency)
3428
panel.set_value("time_points", time_points.tolist())
3529
panel.set_value("sine_values", sine_values.tolist())
30+
panel.set_value("amplitude", amplitude)
31+
panel.set_value("frequency", frequency)
3632

33+
# Slowly vary the frequency for a more dynamic visualization
34+
frequency = 1.0 + 0.5 * math.sin(time.time() / 5.0)
3735
time.sleep(0.1)
3836

3937
except KeyboardInterrupt:

examples/simple_graph/simple_graph_panel.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,30 @@
11
"""A Streamlit visualization panel for the simple_graph.py example script."""
22

33
import streamlit as st
4-
from amplitude_enum import AmplitudeEnum
54
from streamlit_echarts import st_echarts
65

76
import nipanel
87

98

109
st.set_page_config(page_title="Simple Graph Example", page_icon="📈", layout="wide")
1110
st.title("Simple Graph Example")
12-
col1, col2, col3, col4, col5, col6 = st.columns(6)
1311

1412
panel = nipanel.get_panel_accessor()
15-
frequency = panel.get_value("frequency", 0.0)
1613
time_points = panel.get_value("time_points", [0.0])
1714
sine_values = panel.get_value("sine_values", [0.0])
15+
amplitude = panel.get_value("amplitude", 1.0)
16+
frequency = panel.get_value("frequency", 1.0)
1817

18+
col1, col2, col3, col4, col5 = st.columns(5)
1919
with col1:
20-
nipanel.enum_selectbox(panel, label="Amplitude", value=AmplitudeEnum.MEDIUM, key="amplitude")
20+
st.metric("Amplitude", f"{amplitude:.2f}")
2121
with col2:
22-
st.number_input("Base Frequency", value=1.0, step=0.5, key="base_frequency")
23-
with col3:
2422
st.metric("Frequency", f"{frequency:.2f} Hz")
25-
with col4:
23+
with col3:
2624
st.metric("Min Value", f"{min(sine_values):.3f}")
27-
with col5:
25+
with col4:
2826
st.metric("Max Value", f"{max(sine_values):.3f}")
29-
with col6:
27+
with col5:
3028
st.metric("Data Points", len(sine_values))
3129

3230
# Prepare data for echarts

0 commit comments

Comments
 (0)