Skip to content

fix: Deephaven express chart title does not update dynamically#386

Merged
mattrunyon merged 2 commits intodeephaven:mainfrom
mattrunyon:plotly-dynamic-title
Mar 26, 2024
Merged

fix: Deephaven express chart title does not update dynamically#386
mattrunyon merged 2 commits intodeephaven:mainfrom
mattrunyon:plotly-dynamic-title

Conversation

@mattrunyon
Copy link
Copy Markdown
Collaborator

@mattrunyon mattrunyon commented Mar 23, 2024

Fixes #377

The issue was the widget changing and thus the model changing, but the Chart component was not resetting. Chart puts the model layout into its state, so it wasn't updating when the model changed. This could also be fixed in Chart, but this is the simplest fix for the dh.ui scenario in the ticket.

This does not fix a scenario where deephaven-express sends a new title (no widget change) as part of an update as Chart will still keep its layout over the model's layout in that case. AFAIK there's currently no way to do this though

@mattrunyon mattrunyon requested a review from mofojed March 23, 2024 18:48
@mattrunyon mattrunyon self-assigned this Mar 23, 2024
mofojed
mofojed previously approved these changes Mar 23, 2024
const { fetch } = props;
const containerRef = useRef<HTMLDivElement>(null);
const [model, setModel] = useState<PlotlyExpressChartModel>();
const [widgetRevision, setWidgetRevision] = useState(0); // Used to force a clean chart state on widget change
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not get a descriptor in props as well? Pattern I've used elsewhere is memoize on the descriptor to generate a shortid for the element.

Though this seems fine.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the types we only have fetch in WidgetComponentProps. The panel gets the metadata descriptor, but when it's used in dh.ui, the metadata is for the dh.ui widget, not the plotly widget

@mattrunyon
Copy link
Copy Markdown
Collaborator Author

Removed from the panel version because it was failing CI, but working locally. I checked and ChartPanel should handle the scenario where makeModel change properly. It will unmount the Chart component while loading so it should always be a clean state there

@mattrunyon mattrunyon merged commit 556d07c into deephaven:main Mar 26, 2024
@mattrunyon mattrunyon deleted the plotly-dynamic-title branch March 26, 2024 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deephaven express chart title does not update dynamically

2 participants