$( document ).ready(function() {
render_chart();
});
function render_chart(){
var stack = d3.layout.stack();
var dataset = {
"categories": ['06:00','07:00','08:00','09:00','10:00','11:00','12:00','13:00','14:00','15:00','16:00','17:00'],
// When generating the string, the guards names will be
//looped through
"series": ["Guard 1","Guard 2","Guard 3","Guard 4"],
// We might need to set a hard coded upper limit on the number of guards. So we can select from a predefined set of x colors.
"colors": ["#3498db","#e74c3c","#2ecc71", "green"],
// FOr each shiftguard, there will be a new one of these
// layers generated
"layers": [
[
{"y":1,"y0":60,"month":"06:00"},
{"y":2,"y0":18,"month":"07:00"}
],
[
{"y":12,"y0":24,"month":"06:00"},
{"y":18,"y0":33,"month":"10:00"}
],[
{"y":25,"y0":30,"month":"14:00"},
{"y":23,"y0":31,"month":"15:00"},
{"y":11,"y0":26,"month":"16:00"},
{"y":12,"y0":23,"month":"17:00"}
]
]
}
n = dataset["series"].length, // Number of Layers
m = dataset["layers"].length, // Number of Samples in 1 layer
yGroupMax = d3.max(dataset["layers"], function(layer) { return d3.max(layer, function(d) { return d.y0; }); });
yGroupMin = d3.min(dataset["layers"], function(layer) { return d3.min(layer, function(d) {...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.