Built with blockbuilder.org
Created
September 9, 2019 03:53
-
-
Save jwilber/e501f4d98833907ab5a2a4d20405fc48 to your computer and use it in GitHub Desktop.
xkcd line chart
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
license: mit |
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> | |
<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'], | |
datasets: [{ | |
label: 'Plan', | |
data: [30, 70, 200, 100, 100, 100, 1500, 2900, 5000, 800], | |
}, { | |
label: 'Reality', | |
data: [0, 9000, 30, 70, 80, 100, 50, 80, 40, 150], | |
}], | |
}, | |
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