mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
XYChart2: Remove common series name from tooltip items (#86739)
This commit is contained in:
parent
2b3457e6ed
commit
7754d0d4dc
@ -23,6 +23,14 @@ export interface Props {
|
||||
xySeries: XYSeries[];
|
||||
}
|
||||
|
||||
function stripSeriesName(fieldName: string, seriesName: string) {
|
||||
if (fieldName.includes(' ')) {
|
||||
fieldName = fieldName.replace(seriesName, '').trim();
|
||||
}
|
||||
|
||||
return fieldName;
|
||||
}
|
||||
|
||||
export const XYChartTooltip = ({ dataIdxs, seriesIdx, data, xySeries, dismiss, isPinned }: Props) => {
|
||||
const styles = useStyles2(getStyles);
|
||||
|
||||
@ -51,18 +59,18 @@ export const XYChartTooltip = ({ dataIdxs, seriesIdx, data, xySeries, dismiss, i
|
||||
|
||||
const contentItems: VizTooltipItem[] = [
|
||||
{
|
||||
label: xField.state?.displayName ?? xField.name,
|
||||
label: stripSeriesName(xField.state?.displayName ?? xField.name, label),
|
||||
value: fmt(xField, xField.values[rowIndex]),
|
||||
},
|
||||
{
|
||||
label: yField.state?.displayName ?? yField.name,
|
||||
label: stripSeriesName(yField.state?.displayName ?? yField.name, label),
|
||||
value: fmt(yField, yField.values[rowIndex]),
|
||||
},
|
||||
];
|
||||
|
||||
series._rest.forEach((field) => {
|
||||
contentItems.push({
|
||||
label: field.state?.displayName ?? field.name,
|
||||
label: stripSeriesName(field.state?.displayName ?? field.name, label),
|
||||
value: fmt(field, field.values[rowIndex]),
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user