-
-
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(network): add separated node and link components
- v0.88.0
- v0.87.0
- v0.86.0
- v0.85.1
- v0.85.0
- v0.84.0
- v0.83.1
- v0.83.0
- v0.82.1
- v0.82.0
- v0.81.0
- v0.80.0
- v0.79.1
- v0.79.0
- v0.78.0
- v0.77.0
- v0.76.0
- v0.75.0
- v0.74.1
- v0.74.0
- v0.73.1
- v0.73.0
- v0.72.0
- v0.71.0
- v0.70.1
- v0.70.0
- v0.69.1
- v0.69.0
- v0.68.0
- v0.67.0
- v0.66.0
- v0.65.1
- v0.65.0
- v0.64.0
- v0.63.1
- v0.63.0
- v0.62.0
- v0.61.2
- v0.61.1
- v0.61.0
- v0.60.1
- v0.60.0
- v0.59.3
- v0.59.2
- v0.59.1
- v0.59.0
- v0.58.0
- v0.57.2
- v0.57.1
- v0.57.0
Raphaël Benitte
authored and
Raphaël Benitte
committed
May 9, 2019
1 parent
2ea8581
commit a54ac59
Showing
7 changed files
with
193 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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 Link = ({ sourceX, sourceY, targetX, targetY, thickness, color }) => { | ||
return ( | ||
<line | ||
stroke={color} | ||
strokeWidth={thickness} | ||
strokeLinecap="round" | ||
x1={sourceX} | ||
y1={sourceY} | ||
x2={targetX} | ||
y2={targetY} | ||
/> | ||
) | ||
} | ||
|
||
Link.propTypes = { | ||
link: PropTypes.object.isRequired, | ||
sourceX: PropTypes.number.isRequired, | ||
sourceY: PropTypes.number.isRequired, | ||
targetX: PropTypes.number.isRequired, | ||
targetY: PropTypes.number.isRequired, | ||
thickness: PropTypes.number.isRequired, | ||
color: PropTypes.string.isRequired, | ||
} | ||
|
||
export default memo(Link) |
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,35 @@ | ||
/* | ||
* 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 Node = ({ x, y, radius, color, borderWidth, borderColor, scale = 1 }) => { | ||
return ( | ||
<circle | ||
transform={`translate(${x},${y}) scale(${scale})`} | ||
r={radius} | ||
fill={color} | ||
strokeWidth={borderWidth} | ||
stroke={borderColor} | ||
/> | ||
) | ||
} | ||
|
||
Node.propTypes = { | ||
node: PropTypes.object.isRequired, | ||
x: PropTypes.number.isRequired, | ||
y: PropTypes.number.isRequired, | ||
radius: PropTypes.number.isRequired, | ||
color: PropTypes.string.isRequired, | ||
borderWidth: PropTypes.number.isRequired, | ||
borderColor: PropTypes.string.isRequired, | ||
scale: PropTypes.number, | ||
} | ||
|
||
export default memo(Node) |
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,36 @@ | ||
/* | ||
* 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' | ||
import Link from './Link' | ||
|
||
const StaticLinks = ({ links, linkThickness, linkColor }) => { | ||
return links.map(link => { | ||
return ( | ||
<Link | ||
key={link.id} | ||
link={link} | ||
color={linkColor(link)} | ||
thickness={linkThickness(link)} | ||
sourceX={link.source.x} | ||
sourceY={link.source.y} | ||
targetX={link.target.x} | ||
targetY={link.target.y} | ||
/> | ||
) | ||
}) | ||
} | ||
|
||
StaticLinks.propTypes = { | ||
links: PropTypes.array.isRequired, | ||
linkThickness: PropTypes.func.isRequired, | ||
linkColor: PropTypes.func.isRequired, | ||
} | ||
|
||
export default memo(StaticLinks) |
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,37 @@ | ||
/* | ||
* 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' | ||
import Node from './Node' | ||
|
||
const StaticNodes = ({ nodes, color, borderWidth, borderColor }) => { | ||
return nodes.map(node => { | ||
return ( | ||
<Node | ||
key={node.id} | ||
node={node} | ||
x={node.x} | ||
y={node.y} | ||
radius={node.radius} | ||
color={color(node)} | ||
borderWidth={borderWidth} | ||
borderColor={borderColor(node)} | ||
/> | ||
) | ||
}) | ||
} | ||
|
||
StaticNodes.propTypes = { | ||
nodes: PropTypes.array.isRequired, | ||
color: PropTypes.func.isRequired, | ||
borderWidth: PropTypes.number.isRequired, | ||
borderColor: PropTypes.func.isRequired, | ||
} | ||
|
||
export default memo(StaticNodes) |