Simple Bar chart
From http://bl.ocks.org/Caged/6476579
by arvillarruel
JavaScript
// Function for moving nodes to front
d3.selection.prototype.moveToFront = function() {
return this.each(function(){
this.parentNode.appendChild(this);
});
};
// Function for moving to back
d3.selection.prototype.moveToBack = function() {
return this.each(function() {
var firstChild = this.parentNode.firstChild;
if (firstChild) {
this.parentNode.insertBefore(this, firstChild);
}
});
};
var scaleFactor = 1;
var translation = [0,0];
var smallCircleSize = 4.5;
var largeCircleSize = 9;
var minWidthPoly1 = 255;
var minWidthPoly2 = 355;
var xMargin = 20;
var yPosFaculty = 170;
var yPosEntry = 90;
var yMargin = 20;
var legendEntryPadding = 10;
var legendFacultyPadding = 5;
var height = 0;
var width = 0;
// Linear size scale
var linearSize = d3.scale.linear().domain([0,1]).range([smallCircleSize, largeCircleSize]);
// Initialize Ordinal Colour Scale
var color = d3.scale.ordinal()
.domain(["02", "03", "04", "06", "07", "14", "15", "21", "23"])
.range([
"#009933", // Science
"#ff0000", // Engineering
"#003366", // Health Science (Nursing and Midwifery included)
"#996633", // Business
"#ff9933", // Arts and Science
"#ffcccc", // Humanities
"#ff66ff", // Social Science
"#0000cc", // Medicine
"#00ccff", // Interns and Residents
]);
// Configure force layout
var force = d3.layout.force();
...