DC.js - Histogram example

HTML

<script src="http://nickqizhu.github.io/dc.js/js/d3.js"></script>
<script src="http://nickqizhu.github.io/dc.js/js/crossfilter.js"></script>
<link rel="stylesheet" href="http://nickqizhu.github.io/dc.js/css/dc.css">
<script src="http://underscorejs.org/underscore-min.js"></script>
<div id="barChart"></div>

JavaScript

var chartExample = {
    initChart: function (experiments) {
        var barChart = dc.barChart("#barChart");

        var ndx = crossfilter(experiments),
            typeDimension = ndx.dimension(function (d) {
                return d;
            }),
            typeGroup = typeDimension.group().reduceCount();
        
        barChart
            .width(768)
            .height(480)
            .x(d3.scale.linear().domain([0,40]))
            .brushOn(false)
            .dimension(typeDimension)
            .group(typeGroup);

        dc.renderAll();
    },
    initData: function () {
        var experiments = [
            1,
            10,
            1,
            20,
            35,
            24,
            26,
            35,
            12,
            32,
            35,
            10,
            1,
            2,
            32,
            35,
            36,
            12];
        chartExample.initChart(experiments);
    }
};

chartExample.initData();