mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Cleanup tooltip generation in <PieChart>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
a9f4bcecb2
commit
d7019d1426
@ -68,18 +68,11 @@ const NonInjectedPieChart = observer(({
|
||||
const total = datasetData.reduce((acc, cur) => acc + cur, 0);
|
||||
const percent = Math.round((datasetData[tooltipItem.index] as number / total) * 100);
|
||||
const percentLabel = isNaN(percent) ? "N/A" : `${percent}%`;
|
||||
const tooltipLabel = dataset.tooltipLabels?.[tooltipItem.index];
|
||||
let tooltip = `${dataset.label}: ${percentLabel}`;
|
||||
const computeTooltipLabel = dataset.tooltipLabels?.[tooltipItem.index];
|
||||
|
||||
if (tooltipLabel) {
|
||||
if (typeof tooltipLabel === "function") {
|
||||
tooltip = tooltipLabel(percentLabel);
|
||||
} else {
|
||||
tooltip = tooltipLabel;
|
||||
}
|
||||
}
|
||||
|
||||
return tooltip;
|
||||
return computeTooltipLabel
|
||||
? computeTooltipLabel(percentLabel)
|
||||
: `${dataset.label}: ${percentLabel}`;
|
||||
},
|
||||
},
|
||||
filter: ({ datasetIndex, index }, { datasets = [] }) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user