glue-viz / glue-jupyter

Glue front-end for the Jupyter ecosystem
https://glue-jupyter.readthedocs.io/en/latest/
Other
88 stars 38 forks source link

Color widget misbehaves #312

Closed jfoster17 closed 2 years ago

jfoster17 commented 2 years ago

Describe the bug The color widget (i.e. the box next to the eye icon that controls the color of the layer) in the layer options widget has two, potentially related, state bugs.

  1. The color widget initially shows up as white, rather than the color of the data layer. This does NOT happen if the initial color for a dataset is specified at viewer creation (e.g. app.scatter2d(data='dataset1',x='x',y='y',color='red') works just fine).
  2. If you drag in the color widget, instead of clicking distinctly, the color of the layer flickers between the old and the new color in an infinite loop.

To Reproduce

  1. Create a scatter viewer
    import glue_jupyter as gj
    from glue.core import Data
    import numpy as np
    app = gj.jglue()
    dataset1 = Data(x=np.random.rand(100),y=np.random.rand(100),label='test')
    app.add_data(dataset1 = dataset1)
    app.scatter2d(data='dataset1',x='x',y='y')
  2. Open up the layer options. The box showing the color of the layer should be gray, but it is white.3.
  3. Set the color by dragging in the color-picker widget and the color will flicker.4.

Expected behavior The color widget should start in sync with the viewer.layers[0].state.color Dragging in the color picker should not break things.

Video

https://user-images.githubusercontent.com/3639698/169074229-d7e86477-f43a-4713-8dec-0f4a3513c759.mov

Details:

❯ jupyter --version Selected Jupyter core packages... IPython : 8.2.0 ipykernel : 6.12.1 ipywidgets : 7.7.0 jupyter_client : 7.2.2 jupyter_core : 4.9.2 jupyter_server : 1.16.0 jupyterlab : 3.3.3 nbclient : 0.5.13 nbconvert : 6.4.5 nbformat : 5.3.0 notebook : 6.4.10 qtconsole : 5.3.0 traitlets : 5.1.1

Additional context I have shown this for the bqplot scatter viewer, but it seems to impact the matplotlib viewers and the other bqplot viewers as well. I haven't been able to figure out how to get the state of this color-picker directly to write a test for this.

maartenbreddels commented 2 years ago

@mariobuikhuizen maybe you want to take a look at this next week?

mariobuikhuizen commented 2 years ago

I can't reproduce the first part of the issue

jfoster17 commented 2 years ago

Thanks for looking into this. For the first part of the issue, I have discovered that the problem occurs because I had an (older?) settings.cfg file in ~/.glue that specified data_color="0.35". It seems that modern glue saves this as data_color = "#595959" and this does not produce the problem. Similar in spirit to #105 ...

astrofrog commented 2 years ago

@jfoster17 - could you re-open this if some parts of this issue still occur with the latest development version of glue-jupyter?