javascript - Fit the cumulative percentage line to the sorted histogram output with d3 for a pareto chart histogram -


this have far: https://gist.github.com/daluu/fc1cbcab68852ed3c5fa , http://bl.ocks.org/daluu/fc1cbcab68852ed3c5fa. i'm trying replicate excel functionality.

the line fits default histogram fine in base/original http://bl.ocks.org/daluu/f58884c24ff893186416. , i'm able sort histogram in descending frequency, although in doing so, switched x scales (from linear ordinal). can't seem map line sorted histogram correctly @ point. should following examples in terms of visual representation:

  • the excel screenshot in comment in gist referenced above
  • the pareto chart sorted histogram in this post
  • the pareto chart (similar not sorted histogram) made d3 here

what's best design approach remaining part working? should have started single x scale , not need switch linear ordinal? if so, i'm not sure how apply histogram layout correctly using ordinal scale or how not use linear x scale source of input histogram layout , still desired output.

using same ordinal scale code have far, line looks ok it's not curve expecting see.

any appreciated.

the main issue line cumulative distribution needs recalculated after bar sorted, or if you're gunning static pareto chart, cumulative distribution needs calculated in target sort order. purpose i've created small function calculation:

function calccdf(data){   data.foreach(function(d,i){       if(i === 0){       d.cum = d.y/dataset.length     }else{       d.cum = (d.y/dataset.length) + data[i-1].cum     }   })   return data } 

in case, i'm toggling pareto sort on/off , recalculating d.cum property each time. 1 theoretically create 2 cumulative dist properties start with; i.e. d.cum regular ordered distribution , d.paretocum sorted cumulative, i'm using d.cum on tooltip , decided against that.

per axis, i'm using single ordinal scale think cleaner, required work on getting labels meaningful number ranges since tick-marks , labels no longer delineate bins 1 linear scale. solution here use number range tick mark e.g. "1 - 1.99" , add function alternate tickmarks (got solution while ago alternating tick padding in d3.js).

for bar sorting, i'm using d3 example reference in case need understand in context of simpler/smaller example.

see fiddle incorporates of above. if want use it, suggest adding check avoid user being able toggle off both bars , line (left note in code...should trivial)


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -