-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs update code in viz_folder #916
base: master
Are you sure you want to change the base?
docs update code in viz_folder #916
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should convert these to use_reactive
as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also a couple use_state
s 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also use .set
here.
No description provided.