Download script.js from Tommygu/pixelpulse-analytics-dashboard: direct link, hf CLI and curl.
- Browser
- Download file 9.94 kB
-
https://huggingface.co/spaces/Tommygu/pixelpulse-analytics-dashboard/resolve/main/script.js
- Command line
-
hf download hf://spaces/Tommygu/pixelpulse-analytics-dashboard/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Tommygu/pixelpulse-analytics-dashboard/resolve/main/script.js
9.94 kB
| document.addEventListener('DOMContentLoaded', function() { | |
| // Initialize all charts with smooth animations | |
| setTimeout(() => { | |
| initCategoryRevenueChart(); | |
| initCategoryPlaysChart(); | |
| initTopGamesChart(); | |
| initCashBonusChart(); | |
| initRevenueBreakdownChart(); | |
| }, 500); | |
| // Add hover effects to all charts | |
| document.querySelectorAll('canvas').forEach(canvas => { | |
| canvas.style.transition = 'all 0.3s ease'; | |
| canvas.parentElement.addEventListener('mouseenter', () => { | |
| canvas.parentElement.style.transform = 'scale(1.02)'; | |
| canvas.parentElement.style.boxShadow = '0 20px 25px -5px rgba(0, 0, 0, 0.1)'; | |
| }); | |
| canvas.parentElement.addEventListener('mouseleave', () => { | |
| canvas.parentElement.style.transform = 'scale(1)'; | |
| canvas.parentElement.style.boxShadow = ''; | |
| }); | |
| }); | |
| }); | |
| function initCategoryRevenueChart() { | |
| const ctx = document.getElementById('categoryRevenueChart').getContext('2d'); | |
| new Chart(ctx, { | |
| type: 'bar', | |
| data: { | |
| labels: ['Video Games', 'Redemption', 'Cranes', 'Misc'], | |
| datasets: [{ | |
| label: 'Cash Revenue', | |
| data: [400.67, 207.51, 2171.95, 777.20], | |
| backgroundColor: 'rgba(99, 102, 241, 0.7)', | |
| borderColor: 'rgba(99, 102, 241, 1)', | |
| borderWidth: 1 | |
| }, { | |
| label: 'Bonus Revenue', | |
| data: [132.42, 253.55, 490.90, 141.90], | |
| backgroundColor: 'rgba(236, 72, 153, 0.7)', | |
| borderColor: 'rgba(236, 72, 153, 1)', | |
| borderWidth: 1 | |
| }] | |
| }, | |
| options: { | |
| responsive: true, | |
| plugins: { | |
| legend: { | |
| position: 'top', | |
| }, | |
| tooltip: { | |
| callbacks: { | |
| label: function(context) { | |
| return `${context.dataset.label}: $${context.raw.toFixed(2)}`; | |
| } | |
| } | |
| } | |
| }, | |
| scales: { | |
| y: { | |
| beginAtZero: true, | |
| ticks: { | |
| callback: function(value) { | |
| return '$' + value; | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }); | |
| } | |
| function initCategoryPlaysChart() { | |
| const ctx = document.getElementById('categoryPlaysChart').getContext('2d'); | |
| new Chart(ctx, { | |
| type: 'doughnut', | |
| data: { | |
| labels: ['Video Games', 'Redemption', 'Cranes', 'Misc'], | |
| datasets: [{ | |
| data: [287, 174, 1164, 192], | |
| backgroundColor: [ | |
| 'rgba(99, 102, 241, 0.7)', | |
| 'rgba(236, 72, 153, 0.7)', | |
| 'rgba(16, 185, 129, 0.7)', | |
| 'rgba(245, 158, 11, 0.7)' | |
| ], | |
| borderColor: [ | |
| 'rgba(99, 102, 241, 1)', | |
| 'rgba(236, 72, 153, 1)', | |
| 'rgba(16, 185, 129, 1)', | |
| 'rgba(245, 158, 11, 1)' | |
| ], | |
| borderWidth: 1 | |
| }] | |
| }, | |
| options: { | |
| responsive: true, | |
| plugins: { | |
| legend: { | |
| position: 'right', | |
| }, | |
| tooltip: { | |
| callbacks: { | |
| label: function(context) { | |
| return `${context.label}: ${context.raw} plays`; | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }); | |
| } | |
| function initTopGamesChart() { | |
| const ctx = document.getElementById('topGamesChart').getContext('2d'); | |
| new Chart(ctx, { | |
| type: 'bar', | |
| data: { | |
| labels: [ | |
| 'Claw 13 Duck', | |
| 'Blind Box (1 R) Nooki Zoo', | |
| 'Blind Box (2 L) ShinChan', | |
| 'Blind Box (1 L) Samuel Green', | |
| 'Claw 8', | |
| 'Photo Booth Pink', | |
| 'Blind Box (2 R) BIE', | |
| 'Claw 6 Exchange', | |
| 'Big Claw 2 Far', | |
| 'Photo Booth Grey' | |
| ], | |
| datasets: [{ | |
| label: 'Cash Revenue', | |
| data: [212.27, 206.15, 157.99, 148.45, 141.94, 170.00, 140.14, 115.46, 98.03, 103.00], | |
| backgroundColor: 'rgba(99, 102, 241, 0.7)', | |
| borderColor: 'rgba(99, 102, 241, 1)', | |
| borderWidth: 1 | |
| }, { | |
| label: 'Bonus Revenue', | |
| data: [30.60, 44.62, 36.23, 51.75, 0, 5.00, 66.85, 15.50, 27.60, 20.00], | |
| backgroundColor: 'rgba(236, 72, 153, 0.7)', | |
| borderColor: 'rgba(236, 72, 153, 1)', | |
| borderWidth: 1 | |
| }] | |
| }, | |
| options: { | |
| responsive: true, | |
| plugins: { | |
| legend: { | |
| position: 'top', | |
| }, | |
| tooltip: { | |
| callbacks: { | |
| label: function(context) { | |
| return `${context.dataset.label}: $${context.raw.toFixed(2)}`; | |
| } | |
| } | |
| } | |
| }, | |
| scales: { | |
| y: { | |
| beginAtZero: true, | |
| ticks: { | |
| callback: function(value) { | |
| return '$' + value; | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }); | |
| } | |
| function initCashBonusChart() { | |
| const ctx = document.getElementById('cashBonusChart').getContext('2d'); | |
| new Chart(ctx, { | |
| type: 'pie', | |
| data: { | |
| labels: ['Cash Revenue', 'Bonus Revenue'], | |
| datasets: [{ | |
| data: [3594.86, 1018.77], | |
| backgroundColor: [ | |
| 'rgba(99, 102, 241, 0.7)', | |
| 'rgba(236, 72, 153, 0.7)' | |
| ], | |
| borderColor: [ | |
| 'rgba(99, 102, 241, 1)', | |
| 'rgba(236, 72, 153, 1)' | |
| ], | |
| borderWidth: 1 | |
| }] | |
| }, | |
| options: { | |
| responsive: true, | |
| plugins: { | |
| legend: { | |
| position: 'right', | |
| }, | |
| tooltip: { | |
| callbacks: { | |
| label: function(context) { | |
| const total = context.dataset.data.reduce((a, b) => a + b, 0); | |
| const percentage = Math.round((context.raw / total) * 100); | |
| return `${context.label}: $${context.raw.toFixed(2)} (${percentage}%)`; | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }); | |
| } | |
| function initRevenueBreakdownChart() { | |
| const ctx = document.getElementById('revenueBreakdownChart').getContext('2d'); | |
| new Chart(ctx, { | |
| type: 'radar', | |
| data: { | |
| labels: ['Cash Revenue', 'Bonus Revenue', 'Plays', 'Points Redeemed'], | |
| datasets: [ | |
| { | |
| label: 'Video Games', | |
| data: [400.67, 132.42, 287, 0], | |
| backgroundColor: 'rgba(99, 102, 241, 0.2)', | |
| borderColor: 'rgba(99, 102, 241, 1)', | |
| borderWidth: 2, | |
| pointBackgroundColor: 'rgba(99, 102, 241, 1)' | |
| }, | |
| { | |
| label: 'Redemption', | |
| data: [207.51, 253.55, 174, 12672], | |
| backgroundColor: 'rgba(236, 72, 153, 0.2)', | |
| borderColor: 'rgba(236, 72, 153, 1)', | |
| borderWidth: 2, | |
| pointBackgroundColor: 'rgba(236, 72, 153, 1)' | |
| }, | |
| { | |
| label: 'Cranes', | |
| data: [2171.95, 490.90, 1164, 0], | |
| backgroundColor: 'rgba(16, 185, 129, 0.2)', | |
| borderColor: 'rgba(16, 185, 129, 1)', | |
| borderWidth: 2, | |
| pointBackgroundColor: 'rgba(16, 185, 129, 1)' | |
| }, | |
| { | |
| label: 'Misc', | |
| data: [777.20, 141.90, 192, 0], | |
| backgroundColor: 'rgba(245, 158, 11, 0.2)', | |
| borderColor: 'rgba(245, 158, 11, 1)', | |
| borderWidth: 2, | |
| pointBackgroundColor: 'rgba(245, 158, 11, 1)' | |
| } | |
| ] | |
| }, | |
| options: { | |
| responsive: true, | |
| plugins: { | |
| legend: { | |
| position: 'top', | |
| }, | |
| tooltip: { | |
| callbacks: { | |
| label: function(context) { | |
| let label = context.dataset.label || ''; | |
| if (label) { | |
| label += ': '; | |
| } | |
| if (context.parsed.label === 'Points Redeemed') { | |
| label += context.parsed.r.toLocaleString(); | |
| } else if (context.parsed.label === 'Plays') { | |
| label += context.parsed.r; | |
| } else { | |
| label += '$' + context.parsed.r.toFixed(2); | |
| } | |
| return label; | |
| } | |
| } | |
| } | |
| }, | |
| scales: { | |
| r: { | |
| angleLines: { | |
| display: true | |
| }, | |
| suggestedMin: 0 | |
| } | |
| } | |
| } | |
| }); | |
| } |