Skip to content

Commit

Permalink
refactor(Axis): Split axis functions (#671)
Browse files Browse the repository at this point in the history
Split on more smaller functions to reduce complexity

Fix #670
Close #671
  • Loading branch information
netil authored Nov 23, 2018
1 parent 4384882 commit 94d592f
Show file tree
Hide file tree
Showing 10 changed files with 640 additions and 549 deletions.
2 changes: 1 addition & 1 deletion src/api/api.flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ extend(ChartInternal.prototype, {
wait.add([
$$.axes.x
.transition(gt)
.call($$.xAxis.setTransition(gt)),
.call(g => $$.xAxis.setTransition(gt).create(g)),

mainBar
.transition(gt)
Expand Down
19 changes: 11 additions & 8 deletions src/axis/Axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* Copyright (c) 2017 NAVER Corp.
* billboard.js project is licensed under the MIT license
*/
import bbAxis from "./bb.axis";
import CLASS from "../config/classes";
import {capitalize, isFunction, isString, isValue, isEmpty, isNumber, isObjectType} from "../internals/util";
import AxisRenderer from "./AxisRenderer";

const isHorizontal = ($$, forHorizontal) => {
const isRotated = $$.config.axis_rotated;
Expand Down Expand Up @@ -71,7 +71,7 @@ export default class Axis {
orgXScale: $$.x
};

const axis = bbAxis(axisParams)
const axis = new AxisRenderer(axisParams)
.scale($$.zoomScale || scale)
.orient(orient);

Expand Down Expand Up @@ -106,7 +106,8 @@ export default class Axis {
axisName,
tickTextRotate: withoutRotateTickText ? 0 : config.axis_y_tick_rotate
};
const axis = bbAxis(axisParams)

const axis = new AxisRenderer(axisParams)
.scale(scale)
.orient(orient)
.tickFormat(
Expand Down Expand Up @@ -425,7 +426,9 @@ export default class Axis {
.style("top", "0px")
.style("left", "0px");

dummy.call(axis).selectAll("text")
axis.create(dummy);

dummy.selectAll("text")
.each(function() {
maxWidth = Math.max(maxWidth, this.getBoundingClientRect().width);
});
Expand Down Expand Up @@ -542,9 +545,9 @@ export default class Axis {
$$.axes[v].style("opacity", opacity);
});

transitions.axisX.call($$.xAxis);
transitions.axisY.call($$.yAxis);
transitions.axisY2.call($$.y2Axis);
transitions.axisSubX.call($$.subXAxis);
$$.xAxis.create(transitions.axisX);
$$.yAxis.create(transitions.axisY);
$$.y2Axis.create(transitions.axisY2);
$$.subXAxis.create(transitions.axisSubX);
}
}
Loading

0 comments on commit 94d592f

Please sign in to comment.