Skip to content Skip to sidebar Skip to footer

Group Log File Data By Time Interval In D3

I have some log file data that I would like to graph. For one log file, every time an event happens a line is added to the log file. I can get it so that the data looks like this

Solution 1:

As suggested by Adam Pearce, you can get all information here: http://bl.ocks.org/mbostock/3048166

The first step is to define x:

var x = d3.scale.linear()
    .domain([0, 120])
    .range([0, width]);

Then, you just define the number of ticks you want:

// Generate a histogram using twenty uniformly-spaced bins.vardata = d3.layout.histogram()
    .bins(x.ticks(20))
    (values);

With values being defined like this:

// Generate a log-normal distribution with a median of 30 minutes.var values = d3.range(1000).map(d3.random.logNormal(Math.log(30), .4));

So, the secret is behind the d3.layout.histogram().bins and the axis.ticks calls.

Post a Comment for "Group Log File Data By Time Interval In D3"