From 5e9fd991abf762d52ddb0b1b191cd9e515326e43 Mon Sep 17 00:00:00 2001 From: Masayuki Tanaka Date: Mon, 3 Mar 2014 21:36:08 +0900 Subject: [PATCH] Fix bar width when categorized axis --- c3.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/c3.js b/c3.js index 0d43922..433ae56 100644 --- a/c3.js +++ b/c3.js @@ -2117,8 +2117,7 @@ var rectX, rectW; var withY, withSubchart, withTransition, withTransform, withUpdateXDomain, withUpdateOrgXDomain; var hideAxis = hasArcType(c3.data.targets); - var drawBar = generateDrawBar(barIndices), drawBarOnSub = generateDrawBar(barIndices, true); - var xForText = generateXYForText(barIndices, true), yForText = generateXYForText(barIndices, false); + var drawBar, drawBarOnSub, xForText, yForText; var duration; options = isDefined(options) ? options : {}; @@ -2152,6 +2151,11 @@ main.select(".y.axis").style("opacity", hideAxis ? 0 : 1).transition().duration(__axis_rotated ? 0 : duration).call(__axis_rotated ? xAxis : yAxis); main.select(".y2.axis").style("opacity", hideAxis ? 0 : 1).transition().call(yAxis2); + // setup drawer - MEMO: these must be called after axis updated + drawBar = generateDrawBar(barIndices); + xForText = generateXYForText(barIndices, true); + yForText = generateXYForText(barIndices, false); + // Update label position main.select(".x.axis .-axis-x-label").attr("x", width); @@ -2335,6 +2339,8 @@ if (!brush.empty()) { brush.extent(x.orgDomain()).update(); } + // setup drawer - MEMO: this must be called after axis updated + drawBarOnSub = generateDrawBar(barIndices, true); // bars contextBar = context.selectAll('.-bars').selectAll('.-bar') .data(barData);