d3.js - Setting up Scale Domain and Bar Width for multiple bar charts in one page -


i new d3. have large json array pulling d3 via ajax make bar graphs. array used generate multiple slides in bootstrap carousel, each slide element of array (i below) corresponding sub elements. have run issues setting x , y scale's extracting directly large array have put necessary values in separate arrays (although has not solved problem yet).

these arrays, same length number of slides, maxdefectcounts() , numberofbars(). note, not associative arrays/json, data have extracted json.

i height of largest bar in each slide equal maxdefectcounts[i] current slide. width of bar numberofbars[i] / width of svg bar chart bound to.

for y-scale have tried following no luck. i'm not sure if can bind separate data element scale function (note using j instead of in function below not confused i, slide number)

     var y = d3.scale.linear()        .range([height,0])        .data(maxdefectcounts)        .enter()        .domain([0,function(d,j){return d[j];}]); 

for width doing iterating through different bars in d.binsummary , using fixed value of barwidth (this testing). since each slide has different number of bars, proportional numberofbars[i] instead of fixed value

var bar = paretobox.selectall("g")     .data(function(d) {return d.binsummary;})     .enter()     .append("g")     .attr("transform",function(d,j) {         return "translate(" + j * barwidth + ",0)";     }); 

any advice appreciated, thank in advance.

i identified workaround. since independent values needed each slide, built loop takes original json input , builds slide each element. allows extraction of needed information. similar approach used here regard building multiple charts single input array.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -