Skip to content

Instantly share code, notes, and snippets.

@psbrandt
Created January 31, 2024 19:54
Show Gist options
  • Select an option

  • Save psbrandt/82ec94ef33dcc3201d40302b27d8e19f to your computer and use it in GitHub Desktop.

Select an option

Save psbrandt/82ec94ef33dcc3201d40302b27d8e19f to your computer and use it in GitHub Desktop.
<html>
<head>
<title>Chart.js</title>
</head>
<body>
<div style="width: 50%">
<canvas id="myChart"></canvas>
</div>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
const ctx = document.getElementById('myChart');
new Chart(ctx, {
type: 'bar',
data: {
labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
borderWidth: 1
}]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment