deephaven / deephaven-plugins

Deephaven Plugins
6 stars 12 forks source link

Plotly Express Treemap - hover root shows variables #278

Open bmingles opened 5 months ago

bmingles commented 5 months ago

Description

Plotly express treemap is showing variables when hovering the root text

image

Steps to reproduce

Run the following to create a treemap

import deephaven.plot.express as dx

source = read_csv("https://media.githubusercontent.com/media/deephaven/examples/main/StandardAndPoors500Financials/csv/s_and_p_500_market_cap.csv")

treemap_dx = dx.treemap(source, names="Label", parents="Parent")

Hover over the text "root" in the top left.

Expected results

Should show an appropriate tooltip with values

Actual results

Shows tooltip with placeholder variables

Additional details and attachments

Versions

Engine Version: 0.33.0-SNAPSHOT Web UI Version: 0.62.0 Java Version: 21.0.2 Barrage Version: 0.6.0 Browser Name: Chrome 121 OS Name: macOS 10.15.7

jnumainville commented 3 months ago

This is actually a problem of missing data The root label has no parent (in this case it would need to be an empty string to signal to plotly this is a top level parent)

See this code

from deephaven import merge, new_table, read_csv
from deephaven.column import string_col
import deephaven.plot.express as dx

source = read_csv("https://media.githubusercontent.com/media/deephaven/examples/main/StandardAndPoors500Financials/csv/s_and_p_500_market_cap.csv").view(["Parent", "Label"])

new_data = new_table([
    string_col("Parent", [""]),
    string_col("Label", ["root"]),
])

result = merge([source, new_data])

treemap_dx = dx.treemap(result, names="Label", parents="Parent")

I will keep this issue open as, even though the hover root showing variables is not a problem, the labels are not correct. They should be label and parent regardless of column name.