d3 stacked chart test
by Luis Lebolo
HTML
<script src="http://d3js.org/d3.v3.min.js"></script>
<body>
<div class="container">
<label>
<input id="sortChart" type="checkbox" checked="checked" />Sort Values</label>
</div>
</body>
CSS
body {
font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;
}
.bar rect {
shape-rendering: crispEdges;
fill-opacity: .9;
}
.bar rect:hover {
fill-opacity: 1.0;
}
.x-axis {
font: 12px sans-serif;
}
.y-axis {
font: 10px sans-serif;
}
.axis path, .axis line {
fill: none;
stroke: black;
shape-rendering: crispEdges;
}
label {
display: block;
margin: 10px 0px 10px 20px;
}
JavaScript
(function (d3Test, undefined) {
"use strict";
////// CONSTANTS \\\\\\
var STAT_TYPE = "ratio";
var _jsFiddleData = {"records":[{"datasetName":"NCI60","cohort":"NCI60","sampleType":"Cell Line","statistics":[{"type":"ratio","key":"mutation","totalSamples":60,"filteredSamples":[{"type":"mutated","numSamples":11}]}]},{"datasetName":"TCGA","cohort":"LUAD (TCGA)","sampleType":"Patient","statistics":[{"type":"ratio","key":"copynumber","totalSamples":493,"filteredSamples":[{"type":"amplified","numSamples":10},{"type":"deleted","numSamples":4}]},{"type":"ratio","key":"mutation","totalSamples":228,"filteredSamples":[{"type":"mutated","numSamples":18}]}]},{"datasetName":"TCGA","cohort":"STAD (TCGA)","sampleType":"Patient","statistics":[{"type":"ratio","key":"copynumber","totalSamples":306,"filteredSamples":[{"type":"amplified","numSamples":2},{"type":"deleted","numSamples":11}]},{"type":"ratio","key":"mutation","totalSamples":218,"filteredSamples":[{"type":"mutated","numSamples":9}]}]},{"datasetName":"TCGA","cohort":"OV (TCGA)","sampleType":"Patient","statistics":[{"type":"ratio","key":"copynumber","totalSamples":569,"filteredSamples":[{"type":"amplified","numSamples":60},{"type":"deleted","numSamples":20}]},{"type":"ratio","key":"mutation","totalSamples":316,"filteredSamples":[{"type":"mutated","numSamples":2}]}]},{"datasetName":"TCGA","cohort":"DLBC (TCGA)","sampleType":"Patient","statistics":[{"type":"ratio","key":"copynumber","totalSamples":18,"filteredSamples":[{"type":"amplified","numSamples":0},{"type":"deleted","numSamples":1}]}]},{"datasetName":"TCGA","cohort":"LIHC (TCGA)","sampleType":"Patient","statistics":[{"type":"ratio","key":"copynumber","totalSamples":108,"filteredSamples":[{"type":"amplified","numSamples":1},{"type":"deleted","numSamples":6}]}]},{"datasetName":"TCGA","cohort":"SKCM...