Skip to content

Commit

Permalink
fix: grid by default
Browse files Browse the repository at this point in the history
  • Loading branch information
markov00 committed May 25, 2021
1 parent 2c26f98 commit 3b1cfc4
Show file tree
Hide file tree
Showing 19 changed files with 24 additions and 8 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion src/components/legend/_legend.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
.echLegend {
.echLegendList {
display: grid;
grid-template-columns: minmax(0, 1fr);
}
&--horizontal {
.echLegendList {
display: grid;
grid-column-gap: $echLegendColumnGap;
grid-row-gap: $echLegendRowGap;
margin-top: $echLegendRowGap;
Expand Down
4 changes: 2 additions & 2 deletions src/components/legend/position_style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function legendPositionStyle(
left: hAlign === Left ? chart.left + INSIDE_PADDING : undefined,
top: vAlign === Top ? chart.top : undefined,
bottom: vAlign === Bottom ? container.height - chart.top - chart.height : undefined,
height: legendSize.height >= chart.height ? chart.height : undefined,
height: !floating && legendSize.height >= chart.height ? chart.height : undefined,
};
}

Expand All @@ -60,7 +60,7 @@ export function legendPositionStyle(
left: chart.left + INSIDE_PADDING,
top: vAlign === Top ? chart.top : undefined,
bottom: vAlign === Bottom ? container.height - chart.top - chart.height : undefined,
height: legendSize.height >= chart.height ? chart.height : undefined,
height: !floating && legendSize.height >= chart.height ? chart.height : undefined,
};
}

Expand Down
5 changes: 2 additions & 3 deletions src/components/legend/style_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,15 @@ export function getLegendListStyle(
return {
paddingLeft,
paddingRight,
gridTemplateColumns: `repeat(auto-fill, minmax(${legendStyle.verticalWidth}px, 1fr))`,
gridTemplateColumns: `repeat(auto-fill, minmax(${legendStyle.verticalWidth}px, auto))`,
};
}

return {
paddingTop,
paddingBottom,
...(floating && {
display: 'grid',
gridTemplateColumns: `repeat(${clamp(floatingColumns ?? 1, 1, totalItems)}, 1fr`,
gridTemplateColumns: `repeat(${clamp(floatingColumns ?? 1, 1, totalItems)}, auto)`,
}),
};
}
Expand Down
18 changes: 16 additions & 2 deletions stories/legend/13_inside_chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ import { SB_KNOBS_PANEL } from '../utils/storybook';
const dg = new SeededDataGenerator();
const data = dg.generateGroupedSeries(10, 20);
export const Example = () => {
const numberOfSeries = number('Number of series', 5);
const numberOfSeries = number('Number of series', 5, { min: 1, max: 20, step: 1, range: true });
const seriesWithLongName = number('Series with long name', 3, {
min: 0,
max: numberOfSeries - 1,
step: 1,
range: true,
});

const floating: LegendPositionConfig['floating'] = boolean('Inside chart', true, 'Legend');
const floatingColumns: LegendPositionConfig['floatingColumns'] = number(
Expand Down Expand Up @@ -116,7 +122,15 @@ export const Example = () => {
yAccessors={['y']}
stackAccessors={['x']}
splitSeriesAccessors={['g']}
data={data.slice(0, numberOfSeries * 10)}
data={data.slice(0, numberOfSeries * 10).map((d, i) => {
if (i >= seriesWithLongName * 10 && i < seriesWithLongName * 10 + 10) {
return {
...d,
g: 'long name',
};
}
return d;
})}
/>
</Chart>
);
Expand Down

0 comments on commit 3b1cfc4

Please sign in to comment.