Created
April 21, 2020 08:52
-
-
Save thomastay/560935be8d632d2c01be3d9b3d9b9aac to your computer and use it in GitHub Desktop.
Quick Demo of a chartist chart
This file contains hidden or 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
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<link href="/static/chartist/chartist.min.css" rel="stylesheet" /> | |
<script src="/static/chartist/chartist.min.js" > </script> | |
<title>Your title here!</title> | |
</head> | |
<body> | |
<h1> Progress chart! </h1> | |
<div class="ct-chart ct-octave"> </div> | |
<script type="text/javascript"> | |
"use strict"; | |
function getLabels() { | |
const fmt = new Intl.DateTimeFormat('en-US', {'weekday':'short'}); | |
const todayDate = new Date().getDate(); | |
return [4, 3, 2, 1, 0].map((curr) => fmt.format(new Date().setDate(todayDate - curr)) | |
); | |
} | |
new Chartist.Line('.ct-chart', { | |
labels: getLabels(), | |
series: [ | |
[40, 40, 40, 40, 40], | |
[7, 12, 22, 24, 29], | |
] | |
}, { | |
fullWidth: true, | |
chartPadding: { | |
right: 60 | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment