-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(chart): added border radius to bar charts
- Loading branch information
SNosenko
authored and
SNosenko
committed
Oct 1, 2021
1 parent
9d1e888
commit cfd0ad2
Showing
6 changed files
with
359 additions
and
140 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
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,33 @@ | ||
import React from 'react'; | ||
import { RadiusProp } from '../types/seria.types'; | ||
|
||
const getPath = ( | ||
x: number, | ||
y: number, | ||
width: number, | ||
height: number, | ||
radius: RadiusProp | number = 0, | ||
): string => | ||
` | ||
M${x + (typeof radius === 'number' ? radius : radius?.bottomLeft || 0)} ${y + height} | ||
Q${x} ${y + height} ${x} ${y + | ||
height - | ||
(typeof radius === 'number' ? radius : radius?.bottomLeft || 0)} | ||
L${x} ${y + (typeof radius === 'number' ? radius : radius?.topLeft || 0)} | ||
Q${x} ${y} ${x + (typeof radius === 'number' ? radius : radius?.topLeft || 0)} ${y} | ||
L${x + width - (typeof radius === 'number' ? radius : radius?.topRight || 0)} ${y} | ||
Q${x + width} ${y} ${x + width} ${y + | ||
(typeof radius === 'number' ? radius : radius?.topRight || 0)} | ||
L${x + width} ${y + | ||
height - | ||
(typeof radius === 'number' ? radius : radius?.bottomRight || 0)} | ||
Q${x + width} ${y + height} ${x + | ||
width - | ||
(typeof radius === 'number' ? radius : radius?.bottomRight || 0)} ${y + height} | ||
Z | ||
`; | ||
|
||
export const RectBar: React.FC<any> = (props): JSX.Element => { | ||
const { fill, x, y, width, height, radius } = props; | ||
return <path d={getPath(x, y, width, height, radius)} stroke='none' fill={fill} />; | ||
}; |
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
Oops, something went wrong.