Skip to content

Commit 94d592f

Browse files
authored
refactor(Axis): Split axis functions (#671)
Split on more smaller functions to reduce complexity Fix #670 Close #671
1 parent 4384882 commit 94d592f

File tree

10 files changed

+640
-549
lines changed

10 files changed

+640
-549
lines changed

src/api/api.flow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ extend(ChartInternal.prototype, {
309309
wait.add([
310310
$$.axes.x
311311
.transition(gt)
312-
.call($$.xAxis.setTransition(gt)),
312+
.call(g => $$.xAxis.setTransition(gt).create(g)),
313313

314314
mainBar
315315
.transition(gt)

src/axis/Axis.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
* Copyright (c) 2017 NAVER Corp.
33
* billboard.js project is licensed under the MIT license
44
*/
5-
import bbAxis from "./bb.axis";
65
import CLASS from "../config/classes";
76
import {capitalize, isFunction, isString, isValue, isEmpty, isNumber, isObjectType} from "../internals/util";
7+
import AxisRenderer from "./AxisRenderer";
88

99
const isHorizontal = ($$, forHorizontal) => {
1010
const isRotated = $$.config.axis_rotated;
@@ -71,7 +71,7 @@ export default class Axis {
7171
orgXScale: $$.x
7272
};
7373

74-
const axis = bbAxis(axisParams)
74+
const axis = new AxisRenderer(axisParams)
7575
.scale($$.zoomScale || scale)
7676
.orient(orient);
7777

@@ -106,7 +106,8 @@ export default class Axis {
106106
axisName,
107107
tickTextRotate: withoutRotateTickText ? 0 : config.axis_y_tick_rotate
108108
};
109-
const axis = bbAxis(axisParams)
109+
110+
const axis = new AxisRenderer(axisParams)
110111
.scale(scale)
111112
.orient(orient)
112113
.tickFormat(
@@ -425,7 +426,9 @@ export default class Axis {
425426
.style("top", "0px")
426427
.style("left", "0px");
427428

428-
dummy.call(axis).selectAll("text")
429+
axis.create(dummy);
430+
431+
dummy.selectAll("text")
429432
.each(function() {
430433
maxWidth = Math.max(maxWidth, this.getBoundingClientRect().width);
431434
});
@@ -542,9 +545,9 @@ export default class Axis {
542545
$$.axes[v].style("opacity", opacity);
543546
});
544547

545-
transitions.axisX.call($$.xAxis);
546-
transitions.axisY.call($$.yAxis);
547-
transitions.axisY2.call($$.y2Axis);
548-
transitions.axisSubX.call($$.subXAxis);
548+
$$.xAxis.create(transitions.axisX);
549+
$$.yAxis.create(transitions.axisY);
550+
$$.y2Axis.create(transitions.axisY2);
551+
$$.subXAxis.create(transitions.axisSubX);
549552
}
550553
}

0 commit comments

Comments
 (0)