Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #1683 Test with the dh.ui plugin from deephaven/deephaven-plugins#176 Example dashboard code ``` from deephaven import ui, time_table from deephaven.ui import use_memo, use_state from deephaven.plot.figure import Figure def use_wave_input(): """ Demonstrating a custom hook. Creates an input panel that controls the amplitude, frequency, and phase for a wave """ amplitude, set_amplitude = use_state(1.0) frequency, set_frequency = use_state(1.0) phase, set_phase = use_state(1.0) input_panel = ui.flex( ui.slider( label="Amplitude", default_value=amplitude, min_value=-100.0, max_value=100.0, on_change=set_amplitude, step=0.1, ), ui.slider( label="Frequency", default_value=frequency, min_value=-100.0, max_value=100.0, on_change=set_frequency, step=0.1, ), ui.slider( label="Phase", default_value=phase, min_value=-100.0, max_value=100.0, on_change=set_phase, step=0.1, ), direction="column", ) return amplitude, frequency, phase, input_panel @ui.component def multiwave(): amplitude, frequency, phase, wave_input = use_wave_input() tt = use_memo(lambda: time_table("PT1s").update("x=i"), []) t = use_memo( lambda: tt.update( [ f"y_sin={amplitude}*Math.sin({frequency}*x+{phase})", f"y_cos={amplitude}*Math.cos({frequency}*x+{phase})", f"y_tan={amplitude}*Math.tan({frequency}*x+{phase})", ] ), [amplitude, frequency, phase], ) p_sin = use_memo( lambda: Figure().plot_xy(series_name="Sine", t=t, x="x", y="y_sin").show(), [t] ) p_cos = use_memo( lambda: Figure().plot_xy(series_name="Cosine", t=t, x="x", y="y_cos").show(), [t], ) p_tan = use_memo( lambda: Figure().plot_xy(series_name="Tangent", t=t, x="x", y="y_tan").show(), [t], ) return [ ui.column( ui.row( ui.stack( ui.panel(wave_input, title="Wave Input"), ui.panel(t, title="Wave Table"), activeItemIndex=0 ), height=25 ), ui.row( ui.stack(ui.panel(p_sin, title="Sine"), width=50), ui.stack(ui.panel(p_cos, title="Cosine"), width=30), ui.stack(ui.panel(p_tan, title="Tangent")) ) ) ] mw = ui.dashboard(multiwave()) ```
- Loading branch information