Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Vislib Axis #7961

Closed
wants to merge 18 commits into from
Closed
15 changes: 7 additions & 8 deletions src/ui/public/vislib/lib/axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,22 @@ export default function AxisFactory(Private) {
* @returns {D3.Svg.Axis|*} D3 axis function
*/
Axis.prototype.getAxis = function (length) {
const scale = this.getScale(length);
const scale = this.createScale(length);

// Create the d3 axis function
this.axis = d3.svg.axis()
return d3.svg.axis()
.scale(scale)
.tickFormat(this.tickFormat(this.domain))
.ticks(this.tickScale(length))
.orient(this.position);
};

return this.axis;
Axis.prototype.getScale = function () {
return this.scale.scale;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this defined before this.createScale() is called?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why split this function in two?

};

Axis.prototype.getScale = function (length) {
if (!this._scale || length) {
this._scale = this.scale.getScale(length);
}
return this._scale;
Axis.prototype.createScale = function (length) {
return this.scale.getScale(length);
};

Axis.prototype.addInterval = function (interval) {
Expand Down