Skip to content

Instantly share code, notes, and snippets.

@jwilber
Last active September 9, 2019 04:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwilber/7b6305572c833572d8c2a97ed9dd3eb8 to your computer and use it in GitHub Desktop.
Save jwilber/7b6305572c833572d8c2a97ed9dd3eb8 to your computer and use it in GitHub Desktop.
xkcd line chart
license: mit
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.xkcd@1/dist/chart.xkcd.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<body>
<svg class="line-chart"></svg>
<script>
const svg = document.querySelector('.line-chart')
const lineChart = new chartXkcd.Line(svg, {
title: 'Monthly income of an indie developer', // optional
xLabel: 'Month', // optional
yLabel: '$ Dollors', // optional
data: {
labels: ['1', 'two', '3', '4', '555fheofeafn;eafeufhauneaf;dfueaefabefe;afueafebaf;efuoebafe;feoaufbeoafbdo;ada;fhj;ahfouahfajhf;aohfouhalalthebeingsihaenothingsinthekitchennooneisgtettingfoodandthecritiqueisgrowingnvery'],
datasets: [{
label: 'Plan',
data: [30, 70, 200, 100, 100, 100, 100, 200, 500, 500],
},],
},
options: { // optional
yTickCount: 3,
legendPosition: chartXkcd.config.positionType.upLeft
}
});
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment