Skip to content

Instantly share code, notes, and snippets.

@thomastay
Created April 21, 2020 08:52
Show Gist options
  • Save thomastay/560935be8d632d2c01be3d9b3d9b9aac to your computer and use it in GitHub Desktop.
Save thomastay/560935be8d632d2c01be3d9b3d9b9aac to your computer and use it in GitHub Desktop.
Quick Demo of a chartist chart
<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