Skip to content

Perspective pane collapses rows when updating data #7554

@rob-tay

Description

@rob-tay

ALL software version info

panel 1.5.4
Windows, MacOS, Chrome, Edge

Description of expected behavior and the observed behavior

There appears to be a bug with the perspective pane automatically collapsing the hierarchy when the underlying data object is updated - this only seems to happen after clicking to expand or collapse a row. This makes it pretty annoying and difficult to use when a periodic callback is used to refresh the data.

I'd expect the depth of the hierarchy to be retained to whatever is currently visible.

Complete, minimal, self-contained example code that reproduces the issue

import pandas as pd
import numpy as np
import panel as pn
pn.extension('perspective')

def get_data(n=100):
    return pd.DataFrame({'x': np.random.choice(['A', 'B'], size=n), 'y': np.random.choice(['C', 'D'], size=n), 'z': np.random.normal(size=n)})

table = pn.pane.Perspective(get_data(), group_by=['x', 'y'], sizing_mode='stretch_both')

def update_data():
    table.object = get_data()

pn.state.add_periodic_callback(update_data)

pn.Row(table, sizing_mode='stretch_width', height=1000)

Image

After collapsing "A", the rest of the levels will collapse and will get stuck

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions