43 lines
1.3 KiB
JavaScript
Executable File
43 lines
1.3 KiB
JavaScript
Executable File
let incomeExpenseCtx = document.getElementById('incomeExpenseChart').getContext('2d');
|
|
let incomeExpenseChart = new Chart(incomeExpenseCtx, {
|
|
type: 'pie',
|
|
data: {
|
|
labels: ['Pendapatan', 'Pengeluaran'],
|
|
datasets: [{
|
|
label: 'Pendapatan vs Pengeluaran',
|
|
data: [totalIncome, totalExpense],
|
|
backgroundColor: [
|
|
'rgba(75, 192, 192, 0.2)',
|
|
'rgba(255, 99, 132, 0.2)'
|
|
],
|
|
borderColor: [
|
|
'rgb(75, 192, 192)',
|
|
'rgb(255, 99, 132)'
|
|
],
|
|
borderWidth: 1
|
|
}]
|
|
},
|
|
options: {
|
|
responsive: true,
|
|
plugins: {
|
|
legend: {
|
|
position: 'top',
|
|
},
|
|
tooltip: {
|
|
callbacks: {
|
|
label: function (tooltipItem) {
|
|
let rupiahFormat = new Intl.NumberFormat('id-ID', {
|
|
style: 'currency',
|
|
currency: 'IDR',
|
|
maximumFractionDigits: 0,
|
|
useGrouping: true
|
|
}).format(tooltipItem.raw);
|
|
|
|
return tooltipItem.label + ': ' + rupiahFormat.replace('Rp ', 'Rp').replace(/\s/g, '');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|