Skip to content

Commit

Permalink
fix(axis): Correct subchart x axis culling
Browse files Browse the repository at this point in the history
Include subchart x axis on culling process.
Subchart x axis should be aligned with the x axis culling.

Fix #1068
  • Loading branch information
netil authored Sep 5, 2019
1 parent b86e87e commit 8478dd9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 5 additions & 2 deletions spec/internals/axis-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1630,6 +1630,9 @@ describe("AXIS", function() {
culling: true
}
}
},
subchart: {
show: true
}
};
});
Expand All @@ -1641,13 +1644,13 @@ describe("AXIS", function() {
y2: [0, 100, 200, 300, 400]
};

["x", "y", "y2"].forEach(v => {
["subx", "x", "y", "y2"].forEach(v => {
const data = chart.internal.axes[v]
.selectAll(".tick text").filter(function() {
return this.style.display === "block";
}).data();

expect(data).to.be.deep.equal(expected[v]);
expect(data).to.be.deep.equal(expected[v === "subx" ? "x" : v]);
});
}

Expand Down
9 changes: 6 additions & 3 deletions src/axis/Axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -750,15 +750,18 @@ export default class Axis {
const $$ = this.owner;
const config = $$.config;

["x", "y", "y2"].forEach(type => {
["subx", "x", "y", "y2"].forEach(type => {
const axis = $$.axes[type];
const toCull = config[`axis_${type}_tick_culling`];

// subchart x axis should be aligned with x axis culling
const id = type === "subx" ? "x" : type;
const toCull = config[`axis_${id}_tick_culling`];

if (axis && toCull) {
const tickText = axis.selectAll(".tick text");
const tickValues = sortValue(tickText.data());
const tickSize = tickValues.length;
const cullingMax = config[`axis_${type}_tick_culling_max`];
const cullingMax = config[`axis_${id}_tick_culling_max`];
let intervalForCulling;

if (tickSize) {
Expand Down

0 comments on commit 8478dd9

Please sign in to comment.