Skip to content

Commit

Permalink
fix: reinvestigate margin misalignment error
Browse files Browse the repository at this point in the history
  • Loading branch information
dv-usama-ansari committed Nov 20, 2023
1 parent c95a51c commit 358ee11
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
18 changes: 9 additions & 9 deletions src/vis/general/layoutUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ export function beautifyLayout(traces: PlotlyInfo, layout: Partial<PlotlyTypes.L
layout[`xaxis${i > 0 ? i + 1 : ''}`] = {
range: t.xDomain ? t.xDomain : null,
...oldLayout?.[`xaxis${i > 0 ? i + 1 : ''}`],
// automargin,
rangemode: 'tozero',
// tickvals: t.xTicks,
// ticktext: t.xTickLabels,
// text: t.xTicks,
// showline: false,
// showspikes: false,
// spikedash: 'dash',
// ticks: 'outside',
automargin,
// rangemode: 'tozero',
tickvals: t.xTicks,
ticktext: t.xTickLabels,
text: t.xTicks,
showline: false,
showspikes: false,
spikedash: 'dash',
ticks: 'outside',
title: {
standoff: 5,
text: traces.plots.length > 1 ? truncateText(t.xLabel, 15) : truncateText(t.xLabel, 50),
Expand Down
8 changes: 3 additions & 5 deletions src/vis/violin/ViolinVis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ export function ViolinVis({ config, columns, scales, dimensions, selectedList, s
if (plotDiv) {
Plotly.Plots.resize(plotDiv);
}
}, [id, dimensions]);
}, [id, dimensions, traces]);

React.useEffect(() => {
useEffect(() => {
if (!traces) {
return;
}
Expand All @@ -84,9 +84,7 @@ export function ViolinVis({ config, columns, scales, dimensions, selectedList, s
shapes: [],
};

setLayout({ ...layout, ...beautifyLayout(traces, innerLayout, layout, true) });
// WARNING: Do not update when layout changes, that would be an infinite loop.
// eslint-disable-next-line react-hooks/exhaustive-deps
setLayout((prev: Partial<Plotly.Layout>) => ({ ...prev, ...beautifyLayout(traces, innerLayout, prev, true) }));
}, [traces]);

return (
Expand Down

0 comments on commit 358ee11

Please sign in to comment.