mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Little clean up
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
e22f8216e8
commit
39786e7911
@ -23,7 +23,6 @@ export interface PieChartData extends ChartJS.ChartData {
|
||||
export type DatasetTooltipLabel = (percent: string) => string | string;
|
||||
|
||||
interface PieChartDataSets extends ChartJS.ChartDataSets {
|
||||
id?: string;
|
||||
tooltipLabels?: DatasetTooltipLabel[];
|
||||
}
|
||||
|
||||
@ -43,10 +42,10 @@ export class PieChart extends React.Component<PieChartProps> {
|
||||
const dataset = data.datasets[tooltipItem.datasetIndex];
|
||||
const datasetData = dataset.data as number[];
|
||||
const total = datasetData.reduce((acc, cur) => acc + cur, 0);
|
||||
const percent = Math.round((dataset.data[tooltipItem["index"]] as number / total) * 100);
|
||||
const percent = Math.round((dataset.data[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 tooltipLabel = dataset.tooltipLabels?.[tooltipItem.index];
|
||||
let tooltip = `${dataset.label}: ${percentLabel}`;
|
||||
|
||||
if (tooltipLabel) {
|
||||
if (typeof tooltipLabel === "function") {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user