Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
|
I closed and deleted old PR, and this is new PR and already fix the code you mentioned in old PR. If there is still any issue, please let me know. Thank you. |
for more information, see https://pre-commit.ci
…izzy985/solara into docs_update_code_in_viz_folder
for more information, see https://pre-commit.ci
cded5b2 to
32af76f
Compare
| on_selection=lambda data: state.value.update({"selection_data": data}), | ||
| on_click=lambda data: state.value.update({"click_data": data}), | ||
| on_hover=lambda data: state.value.update({"hover_data": data}), | ||
| on_unhover=lambda data: state.value.update({"unhover_data": data}), | ||
| on_deselect=lambda data: state.value.update({"deselect_data": data}), |
There was a problem hiding this comment.
The .update method on a dictionary mutates that dictionary, which means that this won't result in the state being updated. Instead, we should explicitly .set the state with the previous values and the new value, i.e.
| on_selection=lambda data: state.value.update({"selection_data": data}), | |
| on_click=lambda data: state.value.update({"click_data": data}), | |
| on_hover=lambda data: state.value.update({"hover_data": data}), | |
| on_unhover=lambda data: state.value.update({"unhover_data": data}), | |
| on_deselect=lambda data: state.value.update({"deselect_data": data}), | |
| on_selection=lambda data: state.set({**state.value, "selection_data": data}), | |
| on_click=lambda data: state.set({**state.value, "click_data": data}), | |
| on_hover=lambda data: state.set({**state.value, "hover_data": data}), | |
| on_unhover=lambda data: state.set({**state.value, "unhover_data": data}), | |
| on_deselect=lambda data: state.set({**state.value, "deselect_data": data}), |
| @@ -58,20 +58,15 @@ def Page(): | |||
| mouseover_data, set_mouseover_data = solara.use_state(None) | |||
| mouseout_data, set_mouseout_data = solara.use_state(None) | |||
There was a problem hiding this comment.
Should convert these to use_reactive as well.
There was a problem hiding this comment.
There's also a couple use_states still around in this file, but I'm not able to comment directly on those lines it seems.
There was a problem hiding this comment.
Thank you! I already fix these issues, if there is still any problem, please let me know.
|
|
||
| return main | ||
| with solara.Card("Echarts"): | ||
| with solara.ToggleButtonsSingle(value=option.value, on_value=lambda data: setattr(option, "value", data)): |
There was a problem hiding this comment.
I think for simplicity we can just use
| with solara.ToggleButtonsSingle(value=option.value, on_value=lambda data: setattr(option, "value", data)): | |
| with solara.ToggleButtonsSingle(value=option): |
There was a problem hiding this comment.
Also, for future reference, instead of setattr(option, "value", data), you can just use the reactive variables' set function, i.e. option.set(data)
| on_click=lambda e: setattr(click_data, "value", e), | ||
| on_mouseover=lambda e: setattr(mouseover_data, "value", e), | ||
| on_mouseout=lambda e: setattr(mouseout_data, "value", e), |
There was a problem hiding this comment.
We can use click_data.set and so on for these. Since we don't have to do anything to the data, we can just assign the set functions directly:
| on_click=lambda e: setattr(click_data, "value", e), | |
| on_mouseover=lambda e: setattr(mouseover_data, "value", e), | |
| on_mouseout=lambda e: setattr(mouseout_data, "value", e), | |
| on_click=click_data.set, | |
| on_mouseover=mouseover_data.set, | |
| on_mouseout=mouseout_data.set, |
| solara.FloatSlider("Frequency", value=freq.value, on_value=lambda v: setattr(freq, "value", v), min=0, max=10) | ||
| solara.FloatSlider("Phase", value=phase.value, on_value=lambda v: setattr(phase, "value", v), min=0, max=np.pi, step=0.1) |
No description provided.