mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
XY Chart: Show mapped size/color fields in tooltip (#87153)
This commit is contained in:
parent
deb6d27406
commit
0fbfb67b15
@ -53,6 +53,10 @@ export const XYChartPanel2 = (props: Props2) => {
|
|||||||
|
|
||||||
// TODO: React.memo()
|
// TODO: React.memo()
|
||||||
const renderLegend = () => {
|
const renderLegend = () => {
|
||||||
|
if (!props.options.legend.showLegend) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const items: VizLegendItem[] = [];
|
const items: VizLegendItem[] = [];
|
||||||
|
|
||||||
series.forEach((s, idx) => {
|
series.forEach((s, idx) => {
|
||||||
|
@ -40,6 +40,9 @@ export const XYChartTooltip = ({ dataIdxs, seriesIdx, data, xySeries, dismiss, i
|
|||||||
const xField = series.x.field;
|
const xField = series.x.field;
|
||||||
const yField = series.y.field;
|
const yField = series.y.field;
|
||||||
|
|
||||||
|
const sizeField = series.size.field;
|
||||||
|
const colorField = series.color.field;
|
||||||
|
|
||||||
let label = series.name.value;
|
let label = series.name.value;
|
||||||
|
|
||||||
let seriesColor = series.color.fixed;
|
let seriesColor = series.color.fixed;
|
||||||
@ -68,6 +71,21 @@ export const XYChartTooltip = ({ dataIdxs, seriesIdx, data, xySeries, dismiss, i
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// mapped fields for size/color
|
||||||
|
if (sizeField != null) {
|
||||||
|
contentItems.push({
|
||||||
|
label: stripSeriesName(sizeField.state?.displayName ?? sizeField.name, label),
|
||||||
|
value: fmt(sizeField, sizeField.values[rowIndex]),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (colorField != null) {
|
||||||
|
contentItems.push({
|
||||||
|
label: stripSeriesName(colorField.state?.displayName ?? colorField.name, label),
|
||||||
|
value: fmt(colorField, colorField.values[rowIndex]),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
series._rest.forEach((field) => {
|
series._rest.forEach((field) => {
|
||||||
contentItems.push({
|
contentItems.push({
|
||||||
label: stripSeriesName(field.state?.displayName ?? field.name, label),
|
label: stripSeriesName(field.state?.displayName ?? field.name, label),
|
||||||
|
Loading…
Reference in New Issue
Block a user