-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(shape): Fix incorrect area/bar rendering
Fix side-effect caused by #1304, making to return y Axis base value based on the current y Axis scale value. Make sure this to used only non-grouped data and for y Axis min is greater than 0. Fix #1316
- Loading branch information
Showing
3 changed files
with
94 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/** | ||
* Copyright (c) 2017 ~ present NAVER Corp. | ||
* billboard.js project is licensed under the MIT license | ||
*/ | ||
/* eslint-disable */ | ||
/* global describe, beforeEach, it, expect */ | ||
import util from "../assets/util"; | ||
|
||
describe("SHAPE", () => { | ||
let chart; | ||
let args; | ||
|
||
beforeEach(() => { | ||
chart = util.generate(args); | ||
}); | ||
|
||
describe("shapes rendering", () => { | ||
before(() => { | ||
args = { | ||
data: { | ||
columns: [ | ||
["data1", 100, 200, 300, 400, 500], | ||
["data2", -100, -200, -300, -400, -500] | ||
], | ||
types: { | ||
data1: "area-step", | ||
data2: "bar" | ||
}, | ||
axes: { | ||
data1: "y", | ||
data2: "y2" | ||
}, | ||
labels: { | ||
show: true | ||
} | ||
}, | ||
area: { | ||
linearGradient: true | ||
}, | ||
axis: { | ||
y: { | ||
show: true, | ||
min: -1000, | ||
max: 1000 | ||
}, | ||
y2: { | ||
show: true, | ||
min: -1000, | ||
max: 1000 | ||
} | ||
}, | ||
legend: { | ||
show: false | ||
} | ||
}; | ||
}); | ||
|
||
it("area/bars combination with positive and negative values", () => { | ||
const expectedY = 228; | ||
|
||
// check area | ||
let rect = chart.$.line.areas.node().getBoundingClientRect(); | ||
|
||
expect(rect.y + rect.height).to.be.equal(expectedY); | ||
|
||
// check area data label text position | ||
chart.$.text.texts.filter(d => d.id === "data1").each(function() { | ||
expect(this.getBoundingClientRect().y).to.be.below(expectedY); | ||
}); | ||
|
||
// check bars | ||
let height = 0; | ||
|
||
chart.$.bar.bars.each(function() { | ||
rect = this.getBoundingClientRect(); | ||
|
||
expect(rect.y).to.be.equal(expectedY); | ||
expect(rect.height).to.be.above(height); | ||
|
||
height = rect.height; | ||
}); | ||
|
||
// check bars data label text position | ||
chart.$.text.texts.filter(d => d.id === "data2").each(function() { | ||
expect(this.getBoundingClientRect().y).to.be.above(expectedY); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters