XY Chart: Show mapped size/color fields in tooltip (#87153)

This commit is contained in:
Adela Almasan 2024-05-01 08:55:11 -06:00 committed by GitHub
parent deb6d27406
commit 0fbfb67b15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 0 deletions

View File

@ -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) => {

View File

@ -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),