Skip to content

Commit

Permalink
fix(bar): Remove new line chars on path string (#533)
Browse files Browse the repository at this point in the history
New line chars can cause not to export as image properly.

Fix #530
Close #533
  • Loading branch information
netil committed Aug 8, 2018
1 parent fd2cc00 commit 1f9db5a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
6 changes: 5 additions & 1 deletion spec/api/api.export-spec.js
Expand Up @@ -14,7 +14,11 @@ describe("API export", () => {
columns: [
["data1", 30, 200, 100, 400, 150, 250],
["data2", 5000, 2000, 1000, 4000, 1500, 2500]
]
],
types: {
data1: "bar",
data2: "area"
}
}
});
});
Expand Down
14 changes: 6 additions & 8 deletions src/shape/bar.js
Expand Up @@ -140,15 +140,13 @@ extend(ChartInternal.prototype, {
isNegative && pathRadius.reverse();
}

// path string data shouldn't be containing new line chars
// https://github.com/naver/billboard.js/issues/530
const path = isRotated ?
`H${points[1][indexX] - radius} ${pathRadius[0]}
V${points[2][indexY] - radius} ${pathRadius[1]}
H${points[3][indexX]}` :
`V${points[1][indexY] + (isNegative ? -radius : radius)} ${pathRadius[0]}
H${points[2][indexX] - radius} ${pathRadius[1]}
V${points[3][indexY]}`;

return `M${points[0][indexX]},${points[0][indexY]} ${path}z`;
`H${points[1][indexX] - radius} ${pathRadius[0]}V${points[2][indexY] - radius} ${pathRadius[1]}H${points[3][indexX]}` :
`V${points[1][indexY] + (isNegative ? -radius : radius)} ${pathRadius[0]}H${points[2][indexX] - radius} ${pathRadius[1]}V${points[3][indexY]}`;

return `M${points[0][indexX]},${points[0][indexY]}${path}z`;
};
},

Expand Down

0 comments on commit 1f9db5a

Please sign in to comment.