Skip to content

Commit

Permalink
fix(area): Fix unnecessary area element generation
Browse files Browse the repository at this point in the history
Make sure area element to be generated only for area types.

Fix #2826
  • Loading branch information
netil authored Aug 18, 2022
1 parent 9bd47a3 commit d43a1a7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/ChartInternal/shape/line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ export default {

// Areas
if ($$.hasTypeOf("Area")) {
$$.initArea(!area && mainLineEnter.empty() ? mainLineUpdate : mainLineEnter);
const mainLine = (
!area && mainLineEnter.empty() ? mainLineUpdate : mainLineEnter
).filter($$.isAreaType.bind($$));

$$.initArea(mainLine);
}

$$.updateTargetForCircle(targets, mainLineEnter);
Expand Down
26 changes: 25 additions & 1 deletion test/shape/area-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ describe("SHAPE AREA", () => {
});
}


it("check bar path node position: non rotated Axis", () => {
checkBarPathPos("y");
});
Expand All @@ -109,6 +108,31 @@ describe("SHAPE AREA", () => {
it("check bar path node position: rotated Axis", () => {
checkBarPathPos("x");
});

it("set options", () => {
args = {
data: {
columns: [
["data1", 800, 750, 730],
["data2", null, 500, 730]
],
type: "line",
types: {
data1: "area"
}
}
};
});

it("area element should be generated for area type dataset only.", () => {
const {areas} = chart.$.line;

expect(areas.size()).to.be.equal(1);

areas.each(function() {
expect(/undefined/.test(this.getAttribute("d"))).to.be.false;
});
});
});

describe("area-range type generation", () => {
Expand Down

0 comments on commit d43a1a7

Please sign in to comment.