1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Move tooltipLabels into chart datasets

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2022-04-07 16:13:48 +03:00
parent 55f60ff074
commit a426daeabb
3 changed files with 7 additions and 7 deletions

View File

@ -156,16 +156,16 @@ const NonInjectedClusterPieCharts = observer(({ clusterOverviewStore }: Dependen
],
id: "podUsage",
label: "Usage",
tooltipLabels: [
(percent) => `Usage: ${percent}`,
(percent) => `Available: ${percent}`,
],
},
],
labels: [
`Usage: ${podUsage || 0}`,
`Capacity: ${podAllocatableCapacity}`,
],
tooltipLabels: [
(percent) => `Usage: ${percent}`,
(percent) => `Available: ${percent}`,
],
};
return (

View File

@ -13,12 +13,12 @@ import { Badge } from "../badge";
export interface ChartData extends ChartJS.ChartData {
datasets?: ChartDataSets[];
tooltipLabels?: ChartTooltipLabel[];
}
export interface ChartDataSets extends ChartJS.ChartDataSets {
id?: string;
tooltip?: string;
tooltipLabels?: ChartTooltipLabel[];
}
export interface ChartProps {
@ -37,7 +37,7 @@ export interface ChartProps {
className?: string;
}
type ChartTooltipLabel = (percent: string) => string | string;
export type ChartTooltipLabel = (percent: string) => string | string;
export enum ChartKind {
PIE = "pie",

View File

@ -34,7 +34,7 @@ export class PieChart extends React.Component<PieChartProps> {
const total = datasetData.reduce((acc, cur) => acc + cur, 0);
const percent = Math.round((dataset.data[tooltipItem["index"]] as number / total) * 100);
const percentLabel = isNaN(percent) ? "N/A" : `${percent}%`;
const tooltipLabel = data.tooltipLabels?.[tooltipItem["index"]];
const tooltipLabel = dataset.tooltipLabels?.[tooltipItem["index"]];
let tooltip = `${dataset["label"]}: ${percentLabel}`;
if (tooltipLabel) {