Skip to content

Instantly share code, notes, and snippets.

@prl900
Created September 2, 2025 04:59
Show Gist options
  • Select an option

  • Save prl900/0f417dc9a488003f55f91db2b118258d to your computer and use it in GitHub Desktop.

Select an option

Save prl900/0f417dc9a488003f55f91db2b118258d to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bar Chart Widget</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.0/chart.umd.js"></script>
<style>
body {
margin: 0;
padding: 20px;
background-color: #144C44;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.chart-container {
background-color: #144C44;
border-radius: 12px;
padding: 30px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
width: 95%;
max-width: 1200px;
}
canvas {
max-height: 600px;
}
</style>
</head>
<body>
<div class="chart-container">
<canvas id="myChart"></canvas>
</div>
<script>
const ctx = document.getElementById('myChart').getContext('2d');
const data = {
labels: [
"Deepmind Natural Forest",
"National Forest Inventory",
"SLATS",
"NFSWV v7.1",
"VMAP v1.0"
],
datasets: [{
label: 'Values',
data: [0.23, 0.32, 0.36, 0.42, 0.56],
backgroundColor: '#E6F05A',
borderColor: '#E6F05A',
borderWidth: 0,
borderRadius: 0,
hoverBackgroundColor: '#F0F56A',
barThickness: 'flex',
maxBarThickness: 100
}]
};
const config = {
type: 'bar',
data: data,
options: {
responsive: true,
maintainAspectRatio: true,
plugins: {
legend: {
display: false
},
tooltip: {
enabled: true,
backgroundColor: 'rgba(0, 0, 0, 0.8)',
titleColor: '#ffffff',
bodyColor: '#ffffff',
padding: 12,
cornerRadius: 6,
displayColors: false,
callbacks: {
title: function(context) {
return context[0].label;
},
label: function(context) {
return 'Value: ' + context.parsed.y;
}
}
}
},
scales: {
y: {
beginAtZero: true,
max: 0.6,
ticks: {
color: '#ffffff',
font: {
size: 12
},
stepSize: 0.1
},
grid: {
color: 'rgba(255, 255, 255, 0.2)',
borderColor: '#ffffff'
}
},
x: {
ticks: {
color: '#ffffff',
font: {
size: 12
},
maxRotation: 0,
minRotation: 0,
autoSkip: false
},
grid: {
display: false,
borderColor: '#ffffff'
}
}
},
interaction: {
mode: 'nearest',
axis: 'x',
intersect: false
},
animation: {
duration: 1000,
easing: 'easeOutQuart'
}
}
};
const myChart = new Chart(ctx, config);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment