Skip to content

Commit

Permalink
better
Browse files Browse the repository at this point in the history
  • Loading branch information
wkrzywiec committed Nov 30, 2024
1 parent 5018623 commit 7754696
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions services/mankkoo-ui/components/charts/Piechart.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import classes from "./Piechart.module.css"
import { Chart as ChartJS, ArcElement, Tooltip, TooltipItem} from 'chart.js'
import { Chart as ChartJS, ArcElement, Tooltip} from 'chart.js'
import { Pie } from "react-chartjs-2";
import ChartDataLabels from 'chartjs-plugin-datalabels';

Expand All @@ -15,7 +15,7 @@ export interface PieChartData {
data: number[]
}

interface CustomTooltipItem extends TooltipItem<'pie'> {
interface CustomTooltipItem {
_metasets : [{
total: number
}]
Expand Down Expand Up @@ -56,10 +56,10 @@ export default function PieChart({
label: function(context) {
console.log(context.chart)

const currentValue: number = context.raw as number
const currentValue = context.raw as number

const chart = context.chart as CustomTooltipItem
const total: number = chart._metasets[context.datasetIndex].total
const chart = context.chart as unknown as CustomTooltipItem
const total = chart._metasets[context.datasetIndex].total

const percentage = (currentValue/total * 100).toFixed(1);

Expand Down

0 comments on commit 7754696

Please sign in to comment.