d3.js - Can i give spaces between the bar rectangles without adjusting the height attribute? -
in fiddle having horizontal bar graph; want give more space between bars .my fiddle. can tamper height attribute(line:101) , reduce bar heights space seems increased donot want change height. how can increase space between bars without changing height?
code rectangles
 rects = groups.selectall('rect')     .data(function (d) {     return d; })     .enter()     .append('rect')     .attr('x', function (d) {     return xscale(d.x0); })     .attr('y', function (d, i) {     return yscale(d.y); })     .attr('height', function (d) {     return yscale.rangeband(); })     .attr('width', function (d) {     return xscale(d.x); }) 
you're doing in code. when write:
yscale = d3.scale.ordinal()     .domain(months)     .rangeroundbands([0, height], .1); that second argument in rangeroundbands padding between bars:
ordinal.rangeroundbands(interval[, padding[, outerpadding]]) so, need tweak value. check fiddle, using 0.5: https://jsfiddle.net/catbu2oz/
but if you're talking keeping the same height in pixels, there 1 solution: hardcoding height value of bars , increasing range of scale, in fiddle: https://jsfiddle.net/3xaklhfo/
Comments
Post a Comment