From ebd21c089a8ca6570a587f180e8b8f34ff31edcb Mon Sep 17 00:00:00 2001 From: wayanrivan Date: Thu, 24 Apr 2025 14:31:27 +0700 Subject: [PATCH] update graph in dashboard --- src/pages/dashboards/home/blocks/MemberActivity.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/dashboards/home/blocks/MemberActivity.tsx b/src/pages/dashboards/home/blocks/MemberActivity.tsx index bdfd43e..172c019 100644 --- a/src/pages/dashboards/home/blocks/MemberActivity.tsx +++ b/src/pages/dashboards/home/blocks/MemberActivity.tsx @@ -30,19 +30,19 @@ const MemberActivity = ({ startdate, enddate }: Props) => { fetchDataTransactionValue(); }, [startdate, enddate, GetData]); - const percentage = responseTransactionValue?.data?.total_customer_active_percentage ?? 0; + const percentage = parseFloat((responseTransactionValue?.data?.total_customer_active_percentage ?? 0).toFixed(2)) ?? 0; const totalCustomer = responseTransactionValue?.data?.total_customer ?? 0; const activeCustomer = responseTransactionValue?.data?.total_customer_active ?? 0; // Hitung sudut pointer - const angle = 180 - (percentage / 100) * 180; // 180° (kiri bawah) ke 0° (kanan bawah) - const radians = (angle * Math.PI) / 180; // Mengubah derajat ke radian + const angle = (percentage / 100) * 180; // 0° (kiri) ke 180° (kanan) + const radians = (angle * Math.PI) / 180; const radius = 40; // Radius dari setengah lingkaran const center = 50; // Titik pusat lingkaran const pointerLength = 25; // Panjang pointer - const x = center + pointerLength * Math.cos(radians); - const y = center + pointerLength * Math.sin(radians); + const x = center + pointerLength * Math.cos(radians - Math.PI); // offset agar mulai dari kiri + const y = center + pointerLength * Math.sin(radians - Math.PI); // Hitung titik akhir untuk arc aktif const arcAngle = (Math.PI * percentage) / 100;