TimeSeries: Add an option to set legend width (#49126)

* Add an option to set legend width

* Add width to the cue file

* Use legendStyle

Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
This commit is contained in:
Ivan Babrou
2022-05-31 10:16:37 -07:00
committed by GitHub
parent 7156935d12
commit a6693ba62f
4 changed files with 17 additions and 0 deletions

View File

@@ -229,6 +229,7 @@ VizLegendOptions: {
isVisible?: bool
sortBy?: string
sortDesc?: bool
width?: number
calcs: [...string]
} @cuetsy(kind="interface")

View File

@@ -276,6 +276,7 @@ export interface VizLegendOptions {
placement: LegendPlacement;
sortBy?: string;
sortDesc?: boolean;
width?: number;
}
export const defaultVizLegendOptions: Partial<VizLegendOptions> = {

View File

@@ -68,6 +68,11 @@ export const VizLayout: VizLayoutComponentType = ({ width, height, legend, child
if (legendMeasure) {
size = { width: width - legendMeasure.width, height };
}
if (legend.props.width) {
legendStyle.width = legend.props.width;
size = { width: width - legend.props.width, height };
}
break;
}
@@ -115,6 +120,7 @@ export interface VizLayoutLegendProps {
children: React.ReactNode;
maxHeight?: string;
maxWidth?: string;
width?: number;
}
/**

View File

@@ -36,6 +36,15 @@ export function addLegendOptions<T extends OptionsWithLegend>(
],
},
showIf: (c) => c.legend.displayMode !== LegendDisplayMode.Hidden,
})
.addNumberInput({
path: 'legend.width',
name: 'Width',
category: ['Legend'],
settings: {
placeholder: 'Auto',
},
showIf: (c) => c.legend.displayMode !== LegendDisplayMode.Hidden && c.legend.placement === 'right',
});
if (includeLegendCalcs) {