Skip to content

Instantly share code, notes, and snippets.

@exp0nge
Created May 25, 2016 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save exp0nge/683bf967bc33961d9e5f3a1be1c84885 to your computer and use it in GitHub Desktop.
Save exp0nge/683bf967bc33961d9e5f3a1be1c84885 to your computer and use it in GitHub Desktop.
//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