graph-glow-up-guru / script.js
mitdow's picture
hey. i need to give you a screenshot and css and html for some graphs on my website that i hate
260255b verified
Raw
History Blame Contribute Delete
4.6 kB
document.addEventListener('DOMContentLoaded', function() {
// Bar Chart
const barCtx = document.getElementById('barChart').getContext('2d');
new Chart(barCtx, {
type: 'bar',
data: {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
datasets: [{
label: 'Sales',
data: [12, 19, 3, 5, 2, 3],
backgroundColor: 'rgba(59, 130, 246, 0.7)',
borderColor: 'rgba(59, 130, 246, 1)',
borderWidth: 1,
borderRadius: 6
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true
}
},
plugins: {
legend: {
display: false
},
tooltip: {
backgroundColor: 'rgba(0, 0, 0, 0.8)',
titleFont: {
size: 14
},
bodyFont: {
size: 12
}
}
}
}
});
// Line Chart
const lineCtx = document.getElementById('lineChart').getContext('2d');
new Chart(lineCtx, {
type: 'line',
data: {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
datasets: [{
label: 'Active Users',
data: [100, 150, 230, 280, 350, 420],
fill: true,
backgroundColor: 'rgba(168, 85, 247, 0.1)',
borderColor: 'rgba(168, 85, 247, 1)',
borderWidth: 2,
tension: 0.3,
pointBackgroundColor: 'rgba(168, 85, 247, 1)',
pointRadius: 4,
pointHoverRadius: 6
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true
}
},
plugins: {
legend: {
display: false
}
}
}
});
// Pie Chart
const pieCtx = document.getElementById('pieChart').getContext('2d');
new Chart(pieCtx, {
type: 'doughnut',
data: {
labels: ['Product A', 'Product B', 'Product C', 'Product D'],
datasets: [{
data: [30, 25, 20, 25],
backgroundColor: [
'rgba(16, 185, 129, 0.7)',
'rgba(59, 130, 246, 0.7)',
'rgba(245, 158, 11, 0.7)',
'rgba(236, 72, 153, 0.7)'
],
borderColor: [
'rgba(16, 185, 129, 1)',
'rgba(59, 130, 246, 1)',
'rgba(245, 158, 11, 1)',
'rgba(236, 72, 153, 1)'
],
borderWidth: 1
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
position: 'right',
labels: {
boxWidth: 12,
padding: 16
}
}
},
cutout: '70%'
}
});
// Radar Chart
const radarCtx = document.getElementById('radarChart').getContext('2d');
new Chart(radarCtx, {
type: 'radar',
data: {
labels: ['Design', 'Development', 'Marketing', 'Sales', 'Support', 'Innovation'],
datasets: [{
label: 'Team Skills',
data: [85, 90, 70, 80, 75, 95],
backgroundColor: 'rgba(249, 115, 22, 0.2)',
borderColor: 'rgba(249, 115, 22, 1)',
borderWidth: 2,
pointBackgroundColor: 'rgba(249, 115, 22, 1)',
pointRadius: 4
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
r: {
angleLines: {
display: true,
color: 'rgba(0, 0, 0, 0.1)'
},
suggestedMin: 0,
suggestedMax: 100
}
},
plugins: {
legend: {
display: false
}
}
}
});
});