0

d3 is pretty cool and I just got started with it as a novice. There are several examples for histograms and I settled on this one. And I did a brief search for cumulative line chart, cumulative distribution, and cumulative frequency, all with respect to d3 but didn't find anything like what I was looking for, but the closest I came to was this, and in light of a better solution, I will try to pursue that and see if I can customize it for my needs. Ideally though, I'm looking for something akin to what Excel offers in terms of histogram with a cumulative frequency/distribution line overlaid on top (with its axis/label being the y-axis on the right). Is there such an equivalent capability with d3 (ideally available as an example/demo to work off of)? That way I have 1 chart rather than 2.

If no readily available examples/demo, any tips for extending my chosen histogram implementation with the cumulative frequency line on same chart with an axis label to the right? As I'm a novice, it will be hard/tricky for me to figure out on my own.

David
  • 3,223
  • 3
  • 29
  • 41

1 Answers1

3

Would this example be close to what you are looking for? D3 has a histogram layout that does a lot of the computational legwork for you and can be plotted like any other bar graph. Just sum up the count data to create the CDF.

J. T.
  • 54
  • 3
  • Thanks, I somehow overlooked (didn't find/see) that example. – David Jan 27 '16 at 00:31
  • Also, I'm not a math wiz, but it seems like the CDF from the example isn't what I'm looking for, and not sure about "sum up count of data to make CDF" perhaps you can elaborate. For now, I ended up defining CDF with [jStat](https://github.com/jstat/jstat) as `data[i]['cum'] = jstat.normal(jstat.mean(), jstat.stdev()).cdf(data[i].x);` and that seemed to approximate what I'm used to in terms of Excel and statistics during a quick test. I didn't use random data like example but fed in actual data I work with. – David Jan 27 '16 at 00:37
  • Here's my [adapted version of the example](http://bl.ocks.org/daluu/f58884c24ff893186416) and the actual [gist](https://gist.github.com/daluu/f58884c24ff893186416) with screenshot of Excel comparison. – David Jan 27 '16 at 07:48