Skip to content

Commit

Permalink
fix: Deephaven express chart title does not update dynamically (#386)
Browse files Browse the repository at this point in the history
Fixes #377
  • Loading branch information
mattrunyon authored Mar 26, 2024
1 parent 09c8eec commit 556d07c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plugins/plotly-express/src/js/src/PlotlyExpressChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ export function PlotlyExpressChart(
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

useEffect(() => {
let cancelled = false;
async function init() {
const widgetData = await fetch();
if (!cancelled) {
setModel(new PlotlyExpressChartModel(dh, widgetData, fetch));
setWidgetRevision(r => r + 1);
}
}

Expand All @@ -37,6 +39,7 @@ export function PlotlyExpressChart(
<Chart
// eslint-disable-next-line react/jsx-props-no-spreading, @typescript-eslint/ban-ts-comment
// @ts-ignore
key={widgetRevision}
containerRef={containerRef}
model={model}
Plotly={Plotly}
Expand Down

0 comments on commit 556d07c

Please sign in to comment.