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

debug JSON not updating in PerspectiveWidget (and other discrepencies in perspective widget) #2766

Closed jgunstone closed 2 months ago

jgunstone commented 2 months ago

Bug Report

Steps to Reproduce:

from datetime import date, datetime
import numpy as np
import pandas as pd
import perspective
from perspective import PerspectiveWidget, Aggregate, Sort, Plugin
import ipywidgets as w

data = pd.DataFrame({
    "int": np.arange(100),
    "float": [i * 1.5 for i in range(100)],
    "bool": [True for i in range(100)],
    "date": [date.today() for i in range(100)],
    "datetime": [datetime.now() for i in range(100)],
    "string": [str(i) for i in range(100)]
})

dg = perspective.PerspectiveWidget(
    data,
    plugin=Plugin.XBAR,
    aggregates={"datetime": Aggregate.ANY},
    sort=[["date", Sort.DESC]]
)
dg
  1. drag bool into "Group By" field
  2. no change in the debug JSON

Expected Result:

when you make changes to the UI config settings they are updated in the debug JSON

Actual Result:

image

Environment:

fresh install -

environment.yml

name: perspective-test
channels:
  - defaults
  - conda-forge
dependencies:
  - python
  - jupyterlab
  - perspective
(base) jovyan@PORT4028:~/meetings-and-notes/20240925-PerspectiveGridTests$ mamba env create -f environment.yml
(base) jovyan@PORT4028:~/meetings-and-notes/20240925-PerspectiveGridTests$ mamba activate perspective-test
(perspective-test) jovyan@PORT4028:~/meetings-and-notes/20240925-PerspectiveGridTests$ mamba list perspective
# packages in environment at /home/jovyan/miniforge3/envs/perspective-test:
#
# Name                    Version                   Build  Channel
perspective               2.10.1          py311hcf300bf_2    conda-forge

Additional Context:

some other issues I've encountered with the jupyter perspective widget vs the online examples (e.g. https://perspective.finos.org/block/?example=editable). True in both jupyter notebooks and the PerspectiveCSV viewer.

image image

image

dhirschfeld commented 2 months ago

Does the sort actually work for you? It didn't do anything for me when I tested with the PerspectiveWidget

import pandas as pd
import numpy as np
from datetime import date, datetime
today = date.today().toordinal()
data = pd.DataFrame({
    "int": np.arange(100),
    "float": [i * 1.5 for i in range(100)],
    "bool": [True for i in range(100)],
    "date": [date.fromordinal(today + i) for i in range(100)],
    "datetime": [datetime.now() for i in range(100)],
    "string": [str(i) for i in range(100)]
})
PerspectiveWidget(data, sort=[["date", Sort.DESC]])
dhirschfeld commented 2 months ago

If PerspectiveWidget is being given an overhaul it might make sense to leverage the anywidget framework.

texodus commented 2 months ago

Your installation looks broken (at least - the theme CSS + web component + python library are from conflicting versions). I see (at least) two issues:

1) Conda is not a currently supported platform. The builds deployed there may work or not - I have not verified them. We are looking into adding support for this in the future but we won't be backdating support to old Perspective versions, speaking of which .. 2) Perspective 2.10.1 does not support JupyterLab 4. Perspective 3.1.0 is the latest version and does not behave as described.

(Converting this issue to a discussion)