diff --git a/src/config.js b/src/config.js index 0972b12..bc0bd66 100644 --- a/src/config.js +++ b/src/config.js @@ -163,6 +163,7 @@ c3_chart_internal_fn.getDefaultConfig = function () { bar_width_ratio: 0.6, bar_width_max: undefined, bar_zerobased: true, + bar_space: 0, // area area_zerobased: true, // pie diff --git a/src/shape.bar.js b/src/shape.bar.js index bd8403e..096ebb8 100644 --- a/src/shape.bar.js +++ b/src/shape.bar.js @@ -91,14 +91,15 @@ c3_chart_internal_fn.generateGetBarPoints = function (barIndices, isSub) { axis = isSub ? $$.subXAxis : $$.xAxis, barTargetsNum = barIndices.__max__ + 1, barW = $$.getBarW(axis, barTargetsNum), - barX = $$.getShapeX(barW, barTargetsNum, barIndices, !!isSub), + barSpaceWidth = barW * $$.config.bar_space, + barX = $$.getShapeX(barW + barSpaceWidth, barTargetsNum, barIndices, !!isSub), barY = $$.getShapeY(!!isSub), barOffset = $$.getShapeOffset($$.isBarType, barIndices, !!isSub), yScale = isSub ? $$.getSubYScale : $$.getYScale; return function (d, i) { var y0 = yScale.call($$, d.id)(0), offset = barOffset(d, i) || y0, // offset is for stacked bar chart - posX = barX(d), posY = barY(d); + posX = barX(d) + barSpaceWidth / 2, posY = barY(d); // fix posY not to overflow opposite quadrant if ($$.config.axis_rotated) { if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { posY = y0; }