Skip to content

Instantly share code, notes, and snippets.

@novemberkilo
Last active August 29, 2015 14:09
Show Gist options
  • Save novemberkilo/403a6d99366f410f83b9 to your computer and use it in GitHub Desktop.
Save novemberkilo/403a6d99366f410f83b9 to your computer and use it in GitHub Desktop.
A Pen by Navin.
<html>
<head>
<link href="http://cdnjs.cloudflare.com/ajax/libs/c3/0.1.29/c3.css" rel="stylesheet" type="text/css">
<title>D3 Page</title>
<script src="http://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/c3/0.1.29/c3.js"></script>
</head>
<body>
<div id="chart"></div>
</body>
</html>
function student_initials(data) {
students = ['Navin K', 'Martin S', 'Katy P', 'Amanda S', 'Josh K', 'Merryn C', 'Frank R', 'Marcus M', 'Stacey W', 'Mark S', 'Laura A', 'Sara L', 'Garett G', 'SengMing T', 'Brad W', 'Stuart C', 'Lachie C', 'Alex S', 'Matthew S', 'Dorota K']
return students[data]
}
var chart = c3.generate({
data: {
x: 'x',
columns: [
['x', 'NK', 'MS', 'KP', 'AS', 'JK', 'MC', 'FR', 'MM', 'SW', 'MS', 'LA', 'SL', 'GG', 'ST', 'BW', 'SC', 'LC', 'AS', 'MS', 'DK'],
['comprehension', 18, 19, 24, 8, 35, 34, 39, 1, 20, 16, 27, 20, 23, 26, 43, 1, 14, 39, 33, 35],
['spelling', 139, 26, 192, 160, 153, 169, 35, 113, 158, 142, 28, 51, 61, 95, 70, 72, 146, 129, 165, 156],
['quizzes', 91, 81, 95, 96, 97, 90, 84, 92, 88, 82, 88, 87, 88, 90, 98, 93, 84, 87, 91, 92]
],
type: 'bar',
labels: true,
groups: [
['comprehension', 'spelling', 'quizzes']
]
},
axis: {
//rotated: true,
x: { type: 'categorized' }
},
tooltip: {
format: {
title: function (d) { return student_initials(d); }
}
}
});
Stacked Bars in c3.js to spike TER representation
------
Forked from [Akhil](http://codepen.io/akhilgkrish/)'s Pen [leaKq](http://codepen.io/akhilgkrish/pen/leaKq/).
A [Pen](http://codepen.io/novemberkilo/pen/dPywWg) by [Navin](http://codepen.io/novemberkilo) on [CodePen](http://codepen.io/).
[License](http://codepen.io/novemberkilo/pen/dPywWg/license).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment