Commit 2d6fbdba authored by Masayuki Tanaka's avatar Masayuki Tanaka

Add padding.top/bottom and fix transition of axis label - #193

parent 85a57161
...@@ -110,7 +110,9 @@ ...@@ -110,7 +110,9 @@
__size_height = getConfig(['size', 'height']); __size_height = getConfig(['size', 'height']);
var __padding_left = getConfig(['padding', 'left'], 50), var __padding_left = getConfig(['padding', 'left'], 50),
__padding_right = getConfig(['padding', 'right']); __padding_right = getConfig(['padding', 'right'], 0),
__padding_top = getConfig(['padding', 'top'], 0),
__padding_bottom = getConfig(['padding', 'bottom'], 0);
var __zoom_enabled = getConfig(['zoom', 'enabled'], false), var __zoom_enabled = getConfig(['zoom', 'enabled'], false),
__zoom_extent = getConfig(['zoom', 'extent']), __zoom_extent = getConfig(['zoom', 'extent']),
...@@ -416,9 +418,9 @@ ...@@ -416,9 +418,9 @@
// for main, context // for main, context
if (__axis_rotated) { if (__axis_rotated) {
margin = { margin = {
top: getHorizontalAxisHeight('y2'), top: getHorizontalAxisHeight('y2') + __padding_top,
right: getCurrentPaddingRight(), right: getCurrentPaddingRight(),
bottom: getHorizontalAxisHeight('y') + legendHeightForBottom, bottom: getHorizontalAxisHeight('y') + legendHeightForBottom + __padding_bottom,
left: subchartHeight + getCurrentPaddingLeft() left: subchartHeight + getCurrentPaddingLeft()
}; };
margin2 = { margin2 = {
...@@ -429,9 +431,9 @@ ...@@ -429,9 +431,9 @@
}; };
} else { } else {
margin = { margin = {
top: 4, // for top tick text top: 4 + __padding_top, // for top tick text
right: getCurrentPaddingRight(), right: getCurrentPaddingRight(),
bottom: xAxisHeight + subchartHeight + legendHeightForBottom, bottom: xAxisHeight + subchartHeight + legendHeightForBottom + __padding_bottom,
left: getCurrentPaddingLeft() left: getCurrentPaddingLeft()
}; };
margin2 = { margin2 = {
...@@ -885,22 +887,22 @@ ...@@ -885,22 +887,22 @@
}); });
return maxWidth < 0 ? 0 : maxWidth; return maxWidth < 0 ? 0 : maxWidth;
} }
function updateAxisLabels() { function updateAxisLabels(withTransition) {
main.select('.' + CLASS.axisX + ' .' + CLASS.axisXLabel) var axisXLabel = main.select('.' + CLASS.axisX + ' .' + CLASS.axisXLabel),
.transition() axisYLabel = main.select('.' + CLASS.axisY + ' .' + CLASS.axisYLabel),
axisY2Label = main.select('.' + CLASS.axisY2 + ' .' + CLASS.axisY2Label);
(withTransition ? axisXLabel.transition() : axisXLabel)
.attr("x", xForXAxisLabel) .attr("x", xForXAxisLabel)
.attr("dx", dxForXAxisLabel) .attr("dx", dxForXAxisLabel)
.attr("dy", dyForXAxisLabel) .attr("dy", dyForXAxisLabel)
.text(textForXAxisLabel); .text(textForXAxisLabel);
main.select('.' + CLASS.axisY + ' .' + CLASS.axisYLabel) (withTransition ? axisYLabel.transition() : axisYLabel)
.transition()
.attr("x", xForYAxisLabel) .attr("x", xForYAxisLabel)
.attr("dx", dxForYAxisLabel) .attr("dx", dxForYAxisLabel)
.attr("dy", dyForYAxisLabel) .attr("dy", dyForYAxisLabel)
.attr("dy", dyForYAxisLabel) .attr("dy", dyForYAxisLabel)
.text(textForYAxisLabel); .text(textForYAxisLabel);
main.select('.' + CLASS.axisY2 + ' .' + CLASS.axisY2Label) (withTransition ? axisY2Label.transition() : axisY2Label)
.transition()
.attr("x", xForY2AxisLabel) .attr("x", xForY2AxisLabel)
.attr("dx", dxForY2AxisLabel) .attr("dx", dxForY2AxisLabel)
.attr("dy", dyForY2AxisLabel) .attr("dy", dyForY2AxisLabel)
...@@ -3230,6 +3232,9 @@ ...@@ -3230,6 +3232,9 @@
transitions.axisY2.call(y2Axis); transitions.axisY2.call(y2Axis);
transitions.axisSubX.call(subXAxis); transitions.axisSubX.call(subXAxis);
// Update axis label
updateAxisLabels(withTransition);
// show/hide if manual culling needed // show/hide if manual culling needed
if (withUpdateXDomain && targetsToShow.length) { if (withUpdateXDomain && targetsToShow.length) {
if (__axis_x_tick_culling && tickValues) { if (__axis_x_tick_culling && tickValues) {
...@@ -3260,9 +3265,6 @@ ...@@ -3260,9 +3265,6 @@
xForText = generateXYForText(barIndices, true); xForText = generateXYForText(barIndices, true);
yForText = generateXYForText(barIndices, false); yForText = generateXYForText(barIndices, false);
// Update axis label
updateAxisLabels();
// Update sub domain // Update sub domain
subY.domain(y.domain()); subY.domain(y.domain());
subY2.domain(y2.domain()); subY2.domain(y2.domain());
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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