again n again

This commit is contained in:
Randa Firman Putra
2025-11-06 18:31:44 +07:00
parent 133ec36510
commit c77321bc8a
36 changed files with 6363 additions and 185 deletions

View File

@@ -56,8 +56,15 @@ export default function AsalDaerahChart({
},
dataLabels: {
enabled: true,
formatter: function (val: number) {
return val.toString();
formatter: function (val: number, opts: any) {
// Hitung total dari semua data
const allData = opts.w.config.series[0].data;
const total = allData.reduce((sum: number, value: number) => sum + value, 0);
if (total === 0 || val === 0) return '0%';
const percentage = ((val / total) * 100).toFixed(1);
return percentage + '%';
},
style: {
fontSize: '12px',
@@ -127,6 +134,16 @@ export default function AsalDaerahChart({
},
dataLabels: {
...prev.dataLabels,
formatter: function (val: number, opts: any) {
// Hitung total dari semua data
const allData = opts.w.config.series[0].data;
const total = allData.reduce((sum: number, value: number) => sum + value, 0);
if (total === 0 || val === 0) return '0%';
const percentage = ((val / total) * 100).toFixed(0);
return percentage + '%';
},
style: {
...prev.dataLabels?.style,
colors: [theme === 'dark' ? '#fff' : '#000']
@@ -197,9 +214,15 @@ export default function AsalDaerahChart({
setData(result);
// Sort data dari terbesar ke terkecil
const sortedData = result.sort((a, b) => b.jumlah - a.jumlah);
// Hitung total untuk persentase
const totalMahasiswa = sortedData.reduce((sum, item) => sum + item.jumlah, 0);
// Proses data untuk chart
const kabupaten = result.map(item => item.kabupaten);
const jumlah = result.map(item => item.jumlah);
const kabupaten = sortedData.map(item => item.kabupaten);
const jumlah = sortedData.map(item => item.jumlah);
setSeries([{
name: 'Jumlah Mahasiswa',