Created
September 10, 2021 03:33
-
-
Save tjkhara/4737e7c56b989e89d46556f9df3d2e79 to your computer and use it in GitHub Desktop.
Chart.js starter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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