Spaces:
Running
Running
File size: 4,050 Bytes
cbda156 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | document.addEventListener('DOMContentLoaded', function() {
// Initialize all charts
initSalesChart();
initMarketChart();
initGrowthChart();
initTimelineChart();
initDemoChart();
});
function initSalesChart() {
const ctx = document.getElementById('salesChart').getContext('2d');
new Chart(ctx, {
type: 'bar',
data: {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
datasets: [{
label: 'Sales',
data: [65, 59, 80, 81, 56, 55],
backgroundColor: 'rgba(99, 102, 241, 0.7)',
borderColor: 'rgba(99, 102, 241, 1)',
borderWidth: 1
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true
}
}
}
});
}
function initMarketChart() {
const ctx = document.getElementById('marketChart').getContext('2d');
new Chart(ctx, {
type: 'doughnut',
data: {
labels: ['Product A', 'Product B', 'Product C', 'Product D'],
datasets: [{
data: [30, 25, 20, 25],
backgroundColor: [
'rgba(139, 92, 246, 0.7)',
'rgba(124, 58, 237, 0.7)',
'rgba(109, 40, 217, 0.7)',
'rgba(91, 33, 182, 0.7)'
],
borderWidth: 1
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
position: 'bottom'
}
}
}
});
}
function initGrowthChart() {
const ctx = document.getElementById('growthChart').getContext('2d');
new Chart(ctx, {
type: 'line',
data: {
labels: ['2018', '2019', '2020', '2021', '2022', '2023'],
datasets: [{
label: 'Active Users',
data: [1200, 1900, 3000, 5000, 8000, 12000],
fill: false,
backgroundColor: 'rgba(59, 130, 246, 0.7)',
borderColor: 'rgba(59, 130, 246, 1)',
tension: 0.4
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true
}
}
}
});
}
function initTimelineChart() {
const ctx = document.getElementById('timelineChart').getContext('2d');
new Chart(ctx, {
type: 'radar',
data: {
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
datasets: [{
label: 'Activity',
data: [65, 59, 90, 81, 56, 55, 40],
backgroundColor: 'rgba(239, 68, 68, 0.2)',
borderColor: 'rgba(239, 68, 68, 1)',
pointBackgroundColor: 'rgba(239, 68, 68, 1)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgba(239, 68, 68, 1)'
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
r: {
angleLines: {
display: true
},
suggestedMin: 0,
suggestedMax: 100
}
}
}
});
}
function initDemoChart() {
const ctx = document.getElementById('demoChart').getContext('2d');
new Chart(ctx, {
type: 'polarArea',
data: {
labels: ['18-24', '25-34', '35-44', '45-54', '55+'],
datasets: [{
data: [30, 45, 15, 7, 3],
backgroundColor: [
'rgba(234, 179, 8, 0.7)',
'rgba(217, 119, 6, 0.7)',
'rgba(202, 138 |