Created
September 6, 2016 14:10
-
-
Save katogiso/ce77ea5cec5f5635eb70038134f2ce4c to your computer and use it in GitHub Desktop.
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
<head> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.2.1/Chart.min.js"></script> | |
<!-- https://github.com/google/palette.js --> | |
<script src="../../palette.js/palette.js"></script> | |
</head> | |
<body> | |
<canvas id="myChart" width="400" height="400"></canvas> | |
</body> | |
<script> | |
// get palette from palette.js | |
var pal = palette('cb-BuGn', 8 ); | |
var ctx = document.getElementById("myChart").getContext("2d"); | |
var myChart = new Chart(ctx, { | |
type: 'bar', | |
data: { | |
labels: [ "Day1", "Day2", "Day3" ], | |
datasets: [ | |
{ | |
label: "base data", | |
data: [ 27, 33, 49 ], | |
borderColor: '#' + pal[3], | |
backgroundColor: '#' + pal[3], | |
}, | |
{ | |
label: "stacked data", | |
data: [ 10, 15, 22 ], | |
borderColor: '#' + pal[5], | |
backgroundColor: '#' + pal[5], | |
} | |
] | |
}, | |
options: { | |
responsive: false, | |
scales: { | |
xAxes: [{ | |
stacked: true, | |
}], | |
yAxes: [{ | |
stacked: true, | |
ticks: { | |
beginAtZero: true, | |
min: 0 | |
} | |
}] | |
} | |
} | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment