mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
@@ -229,6 +229,7 @@ VizLegendOptions: {
|
||||
isVisible?: bool
|
||||
sortBy?: string
|
||||
sortDesc?: bool
|
||||
width?: number
|
||||
calcs: [...string]
|
||||
} @cuetsy(kind="interface")
|
||||
|
||||
|
||||
@@ -276,6 +276,7 @@ export interface VizLegendOptions {
|
||||
placement: LegendPlacement;
|
||||
sortBy?: string;
|
||||
sortDesc?: boolean;
|
||||
width?: number;
|
||||
}
|
||||
|
||||
export const defaultVizLegendOptions: Partial<VizLegendOptions> = {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user