-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sankey): add support for vertical sankey
- Loading branch information
Raphaël Benitte
authored and
Raphaël Benitte
committed
Mar 23, 2019
1 parent
e0a56eb
commit e299590
Showing
14 changed files
with
244 additions
and
120 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
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,43 @@ | ||
/* | ||
* This file is part of the nivo project. | ||
* | ||
* Copyright 2016-present, Raphaël Benitte. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
import React, { memo } from 'react' | ||
import PropTypes from 'prop-types' | ||
|
||
const SankeyLinkGradient = memo(({ id, layout, startColor, endColor }) => { | ||
const gradientProps = {} | ||
if (layout === 'horizontal') { | ||
gradientProps.x1 = '0%' | ||
gradientProps.x2 = '100%' | ||
gradientProps.y1 = '0%' | ||
gradientProps.y2 = '0%' | ||
} else { | ||
gradientProps.x1 = '0%' | ||
gradientProps.x2 = '0%' | ||
gradientProps.y1 = '0%' | ||
gradientProps.y2 = '100%' | ||
} | ||
|
||
return ( | ||
<linearGradient id={id} spreadMethod="pad" {...gradientProps}> | ||
<stop offset="0%" stopColor={startColor} /> | ||
<stop offset="100%" stopColor={endColor} /> | ||
</linearGradient> | ||
) | ||
}) | ||
|
||
SankeyLinkGradient.propTypes = { | ||
id: PropTypes.string.isRequired, | ||
layout: PropTypes.oneOf(['horizontal', 'vertical']).isRequired, | ||
startColor: PropTypes.string.isRequired, | ||
endColor: PropTypes.string.isRequired, | ||
} | ||
|
||
SankeyLinkGradient.displayName = 'SankeyLinkGradient' | ||
|
||
export default SankeyLinkGradient |
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
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.