mastercut/public/assets/admin/js/chart/top-service.js

38 lines
1.1 KiB
JavaScript
Executable File

let topServiceCtx = document.getElementById('topServiceChart').getContext('2d');
let topServiceLabels = topService.map(topService => topService.name);
let topServiceData = topService.map(topService => topService.transactions_count);
let topServiceBackgroundColors = topServiceData.map(() => getRandomColor());
let topServiceBorderColors = topServiceBackgroundColors.map(color => color.replace('0.2', '1'));
let topServiceChart = new Chart(topServiceCtx, {
type: 'bar',
data: {
labels: topServiceLabels,
datasets: [{
label: 'Jumlah Transaksi',
data: topServiceData,
backgroundColor: topServiceBackgroundColors,
borderColor: topServiceBorderColors,
borderWidth: 1
}]
},
options: {
responsive: true,
plugins: {
legend: {
position: 'top',
},
},
scales: {
x: {
beginAtZero: true
},
y: {
beginAtZero: true
}
}
},
});