Skip to content
This repository has been archived by the owner on Jan 29, 2021. It is now read-only.

Commit

Permalink
Fix: Stacked bar goal line issue(fixes #304) (#305)
Browse files Browse the repository at this point in the history
Co-authored-by: Veera Jagarlamudi <[email protected]>
  • Loading branch information
AshishMotanamGurunadham and Veera81 authored Oct 2, 2020
1 parent 45b4907 commit 2209ee5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/js/controls/Bar/helpers/goalLineHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ const getYAxisRangePosition = (scale) => (bounds) =>
* @returns {number} Height of the region for Y axes
*/
const getRegionHeight = (regionPath, bounds, scale, config) => {
const upperBound = utils.getNumber(regionPath.attr(constants.Y_AXIS));
const upperBound = bounds.end
? round2Decimals(scale[getRegionAxis(bounds)](bounds.end))
: 0;
const lowerBound = bounds.start
? round2Decimals(scale[getRegionAxis(bounds)](bounds.start)) +
constants.DEFAULT_GOAL_LINE_STROKE_WIDTH
Expand Down
18 changes: 18 additions & 0 deletions src/test/unit/controls/Bar/BarRegions-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,24 @@ describe("Bar - Region", () => {
toNumber(regionElement.getAttribute("height"))
).toBeGreaterThan(constants.PADDING.top);
});
it("Sets region height correctly, when start and end are same", () => {
data = utils.deepClone(getInput(valuesDefault));
data.regions = [
{
axis: constants.Y_AXIS,
start: 10,
end: 10,
x: 2
}
];
bar = new Bar(data);
graphDefault.loadContent(bar);
const regionElement = fetchElementByClass(
barGraphContainer,
styles.region
);
expect(toNumber(regionElement.getAttribute("height"))).toBe(5);
});
it("Creates a goal bar when start and end are same", () => {
data = utils.deepClone(getInput(valuesDefault));
data.regions = [
Expand Down

0 comments on commit 2209ee5

Please sign in to comment.