Commit 04bf83bd authored by Masayuki Tanaka's avatar Masayuki Tanaka

Fix bar width for sub chart with zoom

parent b63a86e2
...@@ -422,11 +422,16 @@ ...@@ -422,11 +422,16 @@
} }
return [hasBarType(yTargets) ? 0 : yDomainMin-padding_bottom, yDomainMax+padding_top]; return [hasBarType(yTargets) ? 0 : yDomainMin-padding_bottom, yDomainMax+padding_top];
} }
function getXDomainRatio () { function getXDomainRatio (isSub) {
var domain, extent; var domain, extent;
if (brush.empty()) return 1; if (brush.empty()) return 1;
domain = orgXDomain; if (isSub) {
extent = x.domain(); domain = x.domain();
extent = brush.extent();
} else {
domain = orgXDomain;
extent = x.domain();
}
return (domain[1] - domain[0]) / (extent[1] - extent[0]); return (domain[1] - domain[0]) / (extent[1] - extent[0]);
} }
...@@ -624,12 +629,12 @@ ...@@ -624,12 +629,12 @@
return zeroBased ? offset : scale(d.value) - offset; return zeroBased ? offset : scale(d.value) - offset;
}; };
} }
function getBarW (axis, barTargetsNum) { function getBarW (axis, barTargetsNum, isSub) {
var barW; var barW;
if (isCategorized) { if (isCategorized) {
barW = (axis.tickOffset()*2*0.6) / barTargetsNum; barW = (axis.tickOffset()*2*0.6) / barTargetsNum;
} else { } else {
barW = (((__axis_rotated ? height : width)*getXDomainRatio())/(maxDataCount()-1))*0.6; barW = (((__axis_rotated ? height : width)*getXDomainRatio(isSub))/(maxDataCount()-1))*0.6;
} }
return barW; return barW;
} }
...@@ -1318,7 +1323,7 @@ ...@@ -1318,7 +1323,7 @@
} }
// bars // bars
barW = getBarW(xAxis, barTargetsNum); barW = getBarW(xAxis, barTargetsNum, false);
barH = getBarH(__axis_rotated ? null : height); barH = getBarH(__axis_rotated ? null : height);
barX = getBarX(barW, barTargetsNum, barIndices); barX = getBarX(barW, barTargetsNum, barIndices);
barY = getBarY(barH, barIndices, __axis_rotated); barY = getBarY(barH, barIndices, __axis_rotated);
...@@ -1361,7 +1366,7 @@ ...@@ -1361,7 +1366,7 @@
// subchart // subchart
if (withSubchart && __subchart_show) { if (withSubchart && __subchart_show) {
// bars // bars
barW = getBarW(subXAxis, barTargetsNum); barW = getBarW(subXAxis, barTargetsNum, true);
barH = getBarH(height2, true); barH = getBarH(height2, true);
barX = getBarX(barW, barTargetsNum, barIndices, true); barX = getBarX(barW, barTargetsNum, barIndices, true);
barY = getBarY(barH, barIndices, false, true); barY = getBarY(barH, barIndices, false, true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment