Skip to content

Commit 1d49c93

Browse files
committed
Update PlotManager.tsx
1 parent e1e82f4 commit 1d49c93

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

pecan/src/components/PlotManager.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,18 +232,23 @@ function PlotManager({
232232
});
233233

234234
// Build enum tick labels if there's a single signal with VAL_ definitions
235+
const TICK_MAX_CHARS = 10;
236+
const truncate = (s: string) => s.length > TICK_MAX_CHARS ? s.slice(0, TICK_MAX_CHARS - 1) + "…" : s;
237+
235238
let yaxisEnumConfig = {};
239+
let leftMargin = 60;
236240
if (signals.length === 1) {
237241
const valueDefs = getValueDefs(signals[0].signalName);
238242
if (valueDefs) {
239243
const entries = Object.entries(valueDefs).map(([k, v]) => [parseInt(k), v] as [number, string]);
240244
entries.sort((a, b) => a[0] - b[0]);
241245
yaxisEnumConfig = {
242246
tickvals: entries.map(([k]) => k),
243-
ticktext: entries.map(([, v]) => v),
247+
ticktext: entries.map(([, v]) => truncate(v)),
244248
tickmode: "array",
245249
range: [entries[0][0] - 0.5, entries[entries.length - 1][0] + 0.5],
246250
};
251+
leftMargin = 82;
247252
}
248253
}
249254

@@ -260,7 +265,7 @@ function PlotManager({
260265
autorange: !Object.keys(yaxisEnumConfig).length,
261266
...yaxisEnumConfig,
262267
},
263-
margin: { t: 40, r: 20, b: 40, l: 60 },
268+
margin: { t: 40, r: 20, b: 40, l: leftMargin },
264269
paper_bgcolor: paperBg,
265270
plot_bgcolor: plotBg,
266271
font: { color: fontColor },

0 commit comments

Comments
 (0)