-
-
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(line): new prop enableArea was added to Line chart (#82)
- Loading branch information
Showing
4 changed files
with
131 additions
and
2 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,77 @@ | ||
/* | ||
* 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 from 'react' | ||
import PropTypes from 'prop-types' | ||
import pure from 'recompose/pure' | ||
import { motionPropTypes } from '../../../props' | ||
import SmartMotion from '../../SmartMotion' | ||
|
||
const LineAreas = ({ | ||
areaGenerator, | ||
areaOpacity, | ||
lines, | ||
|
||
// motion | ||
animate, | ||
motionStiffness, | ||
motionDamping, | ||
}) => { | ||
if (animate !== true) { | ||
return ( | ||
<g> | ||
{lines.map(({ id, color: areaColor, points }) => ( | ||
<path | ||
key={id} | ||
d={areaGenerator(points)} | ||
fill={areaColor} | ||
fillOpacity={areaOpacity} | ||
strokeWidth={0} | ||
/> | ||
))} | ||
</g> | ||
) | ||
} | ||
|
||
const springConfig = { | ||
stiffness: motionStiffness, | ||
damping: motionDamping, | ||
} | ||
|
||
return ( | ||
<g> | ||
{lines.map(({ id, color: areaColor, points }) => ( | ||
<SmartMotion | ||
key={id} | ||
style={spring => ({ | ||
d: spring(areaGenerator(points), springConfig), | ||
fill: spring(areaColor, springConfig), | ||
})} | ||
> | ||
{style => ( | ||
<path | ||
key={id} | ||
d={style.d} | ||
fill={areaColor} | ||
fillOpacity={areaOpacity} | ||
strokeWidth={0} | ||
/> | ||
)} | ||
</SmartMotion> | ||
))} | ||
</g> | ||
) | ||
} | ||
|
||
LineAreas.propTypes = { | ||
areaOpacity: PropTypes.number.isRequired, | ||
// motion | ||
...motionPropTypes, | ||
} | ||
|
||
export default pure(LineAreas) |
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