Browse Source

Added "bar.space" parameter to set space between bars in bar charts. (Issue #1327)

pull/1328/head
Kreozot 9 years ago
parent
commit
3da5cedc74
  1. 1
      src/config.js
  2. 5
      src/shape.bar.js

1
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

5
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; }

Loading…
Cancel
Save