Skip to content
This repository has been archived by the owner on Jan 23, 2025. It is now read-only.

Commit

Permalink
fix(legend): fix legend height calc
Browse files Browse the repository at this point in the history
  • Loading branch information
salvoravida committed Jan 24, 2023
1 parent 6fe3019 commit df4ef57
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/charts/src/state/selectors/get_legend_size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ export const getLegendSizeSelector = createCustomCachedSelector(

// top or bottom legend
const width = Math.floor(Math.min(legendItemWidth + spacingBuffer + actionDimension, verticalWidth));
const isSingleLine = (parentDimensions.width - 20) / width > labels.length;
const isSingleLine = (parentDimensions.width - 32) / width > labels.length;
const lines = Math.ceil(labels.length / Math.floor((parentDimensions.width - 32) / width));
return {
height: isSingleLine ? bbox.height + 16 : bbox.height * 2 + 24,
height: isSingleLine ? bbox.height + 16 : bbox.height * lines + (lines * 8 + 8),
width,
margin,
position: legendPosition,
Expand Down

0 comments on commit df4ef57

Please sign in to comment.