Skip to content

Commit

Permalink
Fixed overriding axes text transition.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderby committed Sep 16, 2016
1 parent a06d6e8 commit d14543d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/elements/coords.cartesian.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ export class Cartesian extends Element {
);
}

d3_decorator_wrap_tick_label(axis, transAxis, scale.guide, isHorizontal, scale);
d3_decorator_wrap_tick_label(axis, animationSpeed, scale.guide, isHorizontal, scale);

if (!scale.guide.label.hide) {
d3_decorator_prettify_axis_label(
Expand Down
21 changes: 14 additions & 7 deletions src/utils/d3-decorators.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,13 @@ var d3_decorator_prettify_axis_label = (
}
};

var d3_decorator_wrap_tick_label = (nodeScale, transScale, guide, isHorizontal, logicalScale) => {
var d3_decorator_wrap_tick_label = function (
nodeScale,
animationSpeed,
guide,
isHorizontal,
logicalScale
) {

var angle = utils.normalizeAngle(guide.rotate);

Expand All @@ -278,17 +284,18 @@ var d3_decorator_wrap_tick_label = (nodeScale, transScale, guide, isHorizontal,
let dy = (k * (guide.scaleOrient === 'bottom' || guide.scaleOrient === 'top' ?
(sign < 0 ? 0 : 0.71) :
0.32));
let pt = {

let texts = nodeScale.selectAll('.tick text');
let attrs = {
x: 9 * kRot,
y: 0
};
let dpt = {
y: 0,
dx: (isHorizontal) ? null : `${dy}em`,
dy: `${dy}em`
};

nodeScale.selectAll('.tick text').attr(pt).attr(dpt);
transScale.selectAll('.tick text').attr(pt);
// NOTE: Override d3 axis transition.
texts.attr(attrs);
d3_transition(texts, animationSpeed, 'axisTransition').attr(attrs);
}

var limitFunc = (d) => Math.max(logicalScale.stepSize(d), guide.tickFormatWordWrapLimit);
Expand Down

0 comments on commit d14543d

Please sign in to comment.