finos / perspective

A data visualization and analytics component, especially well-suited for large and/or streaming datasets.
https://perspective.finos.org/
Apache License 2.0
8.6k stars 1.19k forks source link

jupyter: PerspectiveWidget rendering is broken inside VBox #2248

Open tomjakubowski opened 1 year ago

tomjakubowski commented 1 year ago

Bug Report

In Jupyter Lab PerspectiveWidget doesn't render correctly inside a VBox.

Screenshot 2023-06-06 at 4 20 49 PM

You can see that little sliver of the perspective viewer UI on the right hand side of the notebook. I can click and drag the resize grabber, but doing that doesn't make the viewer any taller (or shorter).

Steps to Reproduce:

Create a Jupyter Lab instance, install perspective-python (I got perspective_python-2.2.1-cp310-cp310-macosx_11_0_arm64.whl)

# cell 0
from ipywidgets import Button, HBox, VBox
from perspective import PerspectiveWidget

def button(n):
    return Button(description=n)

# cell 1
# VBox doesn't work
VBox([button("A"), button("B"), PerspectiveWidget({"x": int}), button("D")])

# cell 2
# HBox does work
HBox([button("A"), button("B"), PerspectiveWidget({"x": int}), button("D")])

Expected Result:

See a usable perspective widget

Actual Result:

Only see a sliver of UI, and unable to resize widget

Environment:

Additional Context:

HBox and VBox use flexbox https://ipywidgets.readthedocs.io/en/7.6.3/examples/Widget%20Styling.html#The-VBox-and-HBox-helpers

It may be that fiddling with flexbox properties on the the layout property of the widget and/or the Box containing it could fix this

timkpaine commented 1 year ago

I would expect this to be a duplicate of https://github.com/finos/perspective/discussions/1957 and similar, e.g. perspective expects its container to be sized, it has no size on its own

hanzotutu commented 1 year ago

I am using ipywidgets 8.1.0, and perspective-python 2.3.2. PerspectiveWidget doesn't take keyword argument "layout".

dhirschfeld commented 1 year ago

This sounds like the same issue I saw with the PerspectiveWidget: https://github.com/widgetti/reacton/issues/6#issuecomment-1358818643

There it was suggested by Maarten Breddels that the PerspectiveWidget might not be hooking up the lumino resize events correctly: https://github.com/widgetti/reacton/issues/6#issuecomment-1374039910

He also linked to a PR demonstrating how to use the browser ResizeObserver: https://github.com/bqplot/bqplot/pull/1531

Possibly something to investigate...

jonathanng commented 6 months ago

Anyone able to get this working?

dhirschfeld commented 6 months ago

Anyone able to get this working?

From the linked issue: I was able to work around that by wrapping the perspective table in an Output widget

Not ideal, but at least it was possible. I haven't tried again since though so YMMV.

jgunstone commented 2 months ago

just tried this with a fresh install - my workaround was to put the PerspectiveWidget within an output widget but this feels hacky as a long-term fix

environment.yml

name: perspective-test
channels:
  - defaults
  - conda-forge
dependencies:
  - python
  - jupyterlab
  - perspective
mamba env create -f environment.yml

image