Created
May 25, 2016 23:46
-
-
Save exp0nge/683bf967bc33961d9e5f3a1be1c84885 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
//d3.extent will give us the min AND max, which makes it easy for us to setup a scale for our x-axis | |
var ageMinMax = d3.extent(data, function (d) { | |
return d['AGE']; | |
}); | |
ageDefaultersChart | |
.width(900) | |
.height(250) | |
.dimension(ageDefaultersDim) | |
.group(ageDefaultersDim.group().reduceSum(dc.pluck('default payment next month'))) //this will choose the attribute for those that defaulted | |
.x(d3.scale.linear().domain(ageMinMax)) //setup our x-axis using the previously calculated value | |
.elasticY(true) //lets y-axis freely change as filters change | |
.elasticX(true) | |
.xAxisLabel('Age') //label your axis! | |
.yAxisLabel('People Who Defaulted') | |
.controlsUseVisibility(true); | |
$('#ageDefaulters > a').on('click', function (e) { | |
ageDefaultersChart.filterAll(); | |
dc.redrawAll(); | |
e.preventDefault(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment