plotly / dash-slicer

A volume slicer for Dash
https://dash.plotly.com/slicer
MIT License
24 stars 8 forks source link

Interactive slicer example #48

Closed surchs closed 3 years ago

surchs commented 3 years ago

small example that shows how to link three slicers to an interactive table-like element that both displays the current slicer positions and allows user input to change them.

image

verbose labeling

almarklein commented 3 years ago

Nice! Looking good, and nicely commented so its easy to follow along. Could you also add a docstring at the top to briefly explain the purpose of the example?

CI is stuck on formatting. Run black . to auto-format the code, and flake8 . to check for any linting errors. You may need to pip install -U black flake8 first. This repo uses the latest version of Black, but Plotly projects are pinned to an older version. I could do the black-ing if you want.

surchs commented 3 years ago

ok, I added a short comment at the start. The file was already run through black before, I removed some unused imports now. I am not sure why the CI is failing, but there were some larger CI issues recently (e.g. plotly/dash-html-components#170) edit: apparently it is black failing. So I'll recheck again edit2: Still confused, this is my black output on the current file:

➜ black set_slicer_position_interactively.py 
All done! ✨ 🍰 ✨
1 file left unchanged.
(black) 
almarklein commented 3 years ago

Probably a different version of black. It's annoying :/

surchs commented 3 years ago

One thing I just thought of while implementing this in my own app: why do we even need the secondary slider here? can't we just listen directly for the "drag_value" event from the "builtin" slider? That should also break the circularity, no?

almarklein commented 3 years ago

Yeah, either listening to slicer.slider.drag_value or slicer.state.data should do the trick. The latter may be better, since drag_value is not released yet.

I thought that the extra slider was a deliberate thing to show that it can be done :P

surchs commented 3 years ago

Ah, good point. Yeah let's say that was the intention :). I think it does serve that purpose (to see the difference between drag and mouse-up).

almarklein commented 3 years ago

Yeah, but perhaps still better to remove it, since users won't be able to run the example otherwise, until a new dcc is released (and the users upgrade).

almarklein commented 3 years ago

I just ran black on the code. Let's merge this as-is. We can always remove the sliders later if needed. This example is really nice!