Skip to content

Instantly share code, notes, and snippets.

@tjkhara
Created September 10, 2021 03:33
Show Gist options
  • Save tjkhara/4737e7c56b989e89d46556f9df3d2e79 to your computer and use it in GitHub Desktop.
Save tjkhara/4737e7c56b989e89d46556f9df3d2e79 to your computer and use it in GitHub Desktop.
Chart.js starter
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<title>Document</title>
</head>
<body>
<div>
<canvas id="myChart"></canvas>
</div>
<script type="text/javascript">
const labels = [
'January',
'February',
'March',
'April',
'May',
'June',
];
const data = {
labels: labels,
datasets: [{
label: 'My First dataset',
backgroundColor: 'rgb(255, 99, 132)',
borderColor: 'rgb(255, 99, 132)',
data: [0, 1, 5, 2, 20, 30, 45],
}]
};
const config = {
type: 'line',
data: data,
options: {}
};
// === include 'setup' then 'config' above ===
var myChart = new Chart(
document.getElementById('myChart'),
config
);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment