VizTooltip: Add sizing options (#80306)

Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
Co-authored-by: Adela Almasan <adela.almasan@grafana.com>
This commit is contained in:
Ihor Yeromin
2024-01-18 00:49:09 +02:00
committed by GitHub
parent db83eb30a2
commit cbc84a802d
35 changed files with 195 additions and 65 deletions

View File

@@ -295,6 +295,8 @@ export const CandlestickPanel = ({
/>
);
}}
maxWidth={options.tooltip.maxWidth}
maxHeight={options.tooltip.maxHeight}
/>
) : (
<>

View File

@@ -48,6 +48,7 @@ composableKinds: PanelCfg: {
} @cuetsy(kind="interface")
Options: {
common.OptionsWithLegend
common.OptionsWithTooltip
// Sets which dimensions are used for the visualization
mode: VizDisplayMode & (*"candles+volume" | _)

View File

@@ -61,7 +61,7 @@ export const defaultCandlestickColors: Partial<CandlestickColors> = {
up: 'green',
};
export interface Options extends common.OptionsWithLegend {
export interface Options extends common.OptionsWithLegend, common.OptionsWithTooltip {
/**
* Sets the style of the candlesticks
*/

View File

@@ -394,6 +394,5 @@ const getStyles = (theme: GrafanaTheme2) => ({
wrapper: css({
display: 'flex',
flexDirection: 'column',
width: '280px',
}),
});

View File

@@ -274,6 +274,8 @@ export const HeatmapPanel = ({
/>
);
}}
maxWidth={options.tooltip.maxWidth}
maxHeight={options.tooltip.maxHeight}
/>
)}
<AnnotationsPlugin2

View File

@@ -422,6 +422,26 @@ export const plugin = new PanelPlugin<Options, GraphFieldConfig>(HeatmapPanel)
showIf: (opts) => opts.tooltip.mode !== TooltipDisplayMode.None && config.featureToggles.newVizTooltips,
});
builder.addNumberInput({
path: 'tooltip.maxWidth',
name: 'Max width',
category,
settings: {
integer: true,
placeholder: '300',
},
});
builder.addNumberInput({
path: 'tooltip.maxHeight',
name: 'Max height',
category,
settings: {
integer: true,
placeholder: '600',
},
});
category = ['Legend'];
builder.addBooleanSwitch({
path: 'legend.show',

View File

@@ -79,7 +79,9 @@ composableKinds: PanelCfg: lineage: {
// Controls tooltip options
HeatmapTooltip: {
// Controls how the tooltip is shown
mode: ui.TooltipDisplayMode
mode: ui.TooltipDisplayMode
maxHeight?: number
maxWidth?: number
// Controls if the tooltip shows a histogram of the y-axis values
yHistogram?: bool
// Controls if the tooltip shows a color scale in header

View File

@@ -126,6 +126,8 @@ export interface FilterValueRange {
* Controls tooltip options
*/
export interface HeatmapTooltip {
maxHeight?: number;
maxWidth?: number;
/**
* Controls how the tooltip is shown
*/

View File

@@ -236,6 +236,8 @@ export const StateTimelinePanel = ({
/>
);
}}
maxWidth={options.tooltip.maxWidth}
maxHeight={options.tooltip.maxHeight}
/>
)}
{/* Renders annotations */}

View File

@@ -19,7 +19,6 @@ import { VizTooltipContent } from '@grafana/ui/src/components/VizTooltip/VizTool
import { VizTooltipFooter } from '@grafana/ui/src/components/VizTooltip/VizTooltipFooter';
import { VizTooltipHeader } from '@grafana/ui/src/components/VizTooltip/VizTooltipHeader';
import { ColorIndicator, ColorPlacement, LabelValue } from '@grafana/ui/src/components/VizTooltip/types';
import { DEFAULT_TOOLTIP_WIDTH } from '@grafana/ui/src/components/uPlot/plugins/TooltipPlugin2';
import { findNextStateIndex, fmtDuration } from 'app/core/components/TimelineChart/utils';
import { getDataLinks } from '../status-history/utils';
@@ -193,6 +192,5 @@ const getStyles = (theme: GrafanaTheme2) => ({
wrapper: css({
display: 'flex',
flexDirection: 'column',
width: DEFAULT_TOOLTIP_WIDTH,
}),
});

View File

@@ -263,6 +263,8 @@ export const StatusHistoryPanel = ({
/>
);
}}
maxWidth={options.tooltip.maxWidth}
maxHeight={options.tooltip.maxHeight}
/>
)}
<AnnotationsPlugin2

View File

@@ -154,6 +154,5 @@ const getStyles = (theme: GrafanaTheme2) => ({
wrapper: css({
display: 'flex',
flexDirection: 'column',
width: '280px',
}),
});

View File

@@ -141,6 +141,8 @@ export const TimeSeriesPanel = ({
/>
);
}}
maxWidth={options.tooltip.maxWidth}
maxHeight={options.tooltip.maxHeight}
/>
) : (
<>

View File

@@ -19,7 +19,6 @@ import { VizTooltipContent } from '@grafana/ui/src/components/VizTooltip/VizTool
import { VizTooltipFooter } from '@grafana/ui/src/components/VizTooltip/VizTooltipFooter';
import { VizTooltipHeader } from '@grafana/ui/src/components/VizTooltip/VizTooltipHeader';
import { ColorIndicator, ColorPlacement, LabelValue } from '@grafana/ui/src/components/VizTooltip/types';
import { DEFAULT_TOOLTIP_WIDTH } from '@grafana/ui/src/components/uPlot/plugins/TooltipPlugin2';
import { getDataLinks } from '../status-history/utils';
@@ -160,6 +159,5 @@ const getStyles = (theme: GrafanaTheme2) => ({
wrapper: css({
display: 'flex',
flexDirection: 'column',
width: DEFAULT_TOOLTIP_WIDTH,
}),
});

View File

@@ -145,6 +145,8 @@ export const TrendPanel = ({
/>
);
}}
maxWidth={options.tooltip.maxWidth}
maxHeight={options.tooltip.maxHeight}
/>
) : (
<TooltipPlugin

View File

@@ -240,6 +240,8 @@ export const XYChartPanel = (props: Props) => {
/>
);
}}
maxWidth={props.options.tooltip.maxWidth}
maxHeight={props.options.tooltip.maxHeight}
/>
)}
</UPlotChart>

View File

@@ -131,6 +131,5 @@ const getStyles = (theme: GrafanaTheme2) => ({
wrapper: css({
display: 'flex',
flexDirection: 'column',
width: '280px',
}),
});