Skip to content

Commit

Permalink
fix(axis): Correct axis label position (#538)
Browse files Browse the repository at this point in the history
- Correct .getMaxTickWidth() to get last max axis width value
- Some refactorings
- Fix side effect caused by #519

Fix #534
Close #538
  • Loading branch information
netil authored Aug 10, 2018
1 parent 1f9db5a commit 37cca8c
Show file tree
Hide file tree
Showing 6 changed files with 200 additions and 163 deletions.
55 changes: 55 additions & 0 deletions spec/api/api.load-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,59 @@ describe("API load", function() {
});
});
});

describe("y Axis Label", () => {
before(() => {
args = {
data: {
columns: [
['data1', 30, 200, 100, 400, 150],
['data2', 45, 423, 356, 478, 166]
],
axes: {
data1: "y",
data2: "y2"
}
},
axis: {
y: {
label: {
text: "Y Label",
position: "outer-middle"
},
tick: {
count: 5,
format: d3.format("$,")
}
},
y2:{
show:true,
label: {
text: "Y2 Label",
position: "outer-middle"
}
}
}
}
});

it("should be updated the axis label position ", done => {
const axisLabel = chart.$.main.select(`.${CLASS.axisYLabel}`);
const dy = +axisLabel.attr("dy");

chart.load({
columns: [
["data5", 2300000, 1900000, 3000000, 5000000, 3000000]
],
unload: ["data1"],
done: () => {
setTimeout(() => {
expect(+axisLabel.attr("dy")).to.be.below(dy);
done();
}, 500);
}
});

})
});
});
4 changes: 2 additions & 2 deletions src/api/api.load.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* billboard.js project is licensed under the MIT license
*/
import Chart from "../internals/Chart";
import {extend, isString, isArray, isBoolean} from "../internals/util";
import {extend, isString, isArray} from "../internals/util";

extend(Chart.prototype, {
/**
Expand Down Expand Up @@ -80,7 +80,7 @@ extend(Chart.prototype, {
// unload if needed
if ("unload" in args && args.unload !== false) {
// TODO: do not unload if target will load (included in url/rows/columns)
$$.unload($$.mapToTargetIds(isBoolean(args.unload) && args.unload ? null : args.unload), () =>
$$.unload($$.mapToTargetIds(args.unload === true ? null : args.unload), () =>
$$.loadFromArgs(args)
);
} else {
Expand Down
Loading

0 comments on commit 37cca8c

Please sign in to comment.