Commit 751a07e3 by kay delaney Committed by GitHub

Panel/BarGauge: Prevent overflow in panel with many series (#26926)

* Panel/BarGauge: Prevent overflow in panel with many series
Closes #24889
parent 2093f7c1
......@@ -24,6 +24,7 @@ interface Props<V, D> {
itemSpacing?: number;
/** When orientation is set to auto layout items in a grid */
autoGrid?: boolean;
minVizHeight?: number;
}
export interface VizRepeaterRenderValueProps<V, D = {}> {
......@@ -137,7 +138,7 @@ export class VizRepeater<V, D = {}> extends PureComponent<Props<V, D>, State<V>>
}
render() {
const { renderValue, height, width, itemSpacing, getAlignmentFactors, autoGrid, orientation } = this
const { renderValue, height, width, itemSpacing, getAlignmentFactors, autoGrid, orientation, minVizHeight } = this
.props as PropsWithDefaults<V, D>;
const { values } = this.state;
......@@ -151,6 +152,7 @@ export class VizRepeater<V, D = {}> extends PureComponent<Props<V, D>, State<V>>
const repeaterStyle: React.CSSProperties = {
display: 'flex',
overflow: minVizHeight ? 'hidden scroll' : 'visible',
};
let vizHeight = height;
......@@ -161,9 +163,10 @@ export class VizRepeater<V, D = {}> extends PureComponent<Props<V, D>, State<V>>
switch (resolvedOrientation) {
case VizOrientation.Horizontal:
repeaterStyle.flexDirection = 'column';
repeaterStyle.height = `${height}px`;
itemStyles.marginBottom = `${itemSpacing}px`;
vizWidth = width;
vizHeight = height / values.length - itemSpacing + itemSpacing / values.length;
vizHeight = Math.max(height / values.length - itemSpacing + itemSpacing / values.length, minVizHeight ?? 0);
break;
case VizOrientation.Vertical:
repeaterStyle.flexDirection = 'row';
......
......@@ -100,6 +100,7 @@ export class BarGaugePanel extends PureComponent<PanelProps<BarGaugeOptions>> {
renderCounter={renderCounter}
width={width}
height={height}
minVizHeight={10}
itemSpacing={this.getItemSpacing()}
orientation={options.orientation}
/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment