Spaces:
Running

clicktrack-vizpulse / script.js
End3rs's picture
Email Name Link Clicks % Clicks People % People
cbda156 verified
Raw History Blame Contribute Delete
4.05 kB
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