-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dev | Examples | Graph: SVG Icons, curved links, long labels
- Loading branch information
Showing
9 changed files
with
108 additions
and
1 deletion.
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
3 changes: 3 additions & 0 deletions
3
packages/dev/src/examples/networks-and-flows/graph/graph-custom-icons/bucket.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions
7
packages/dev/src/examples/networks-and-flows/graph/graph-custom-icons/index.module.css
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,7 @@ | ||
.graph { | ||
--vis-graph-node-label-font-size: 8pt; | ||
--vis-graph-node-label-text-color: #717179; | ||
|
||
--vis-graph-node-sublabel-font-size: 9pt; | ||
--vis-graph-node-sublabel-text-color: #000000; | ||
} |
68 changes: 68 additions & 0 deletions
68
packages/dev/src/examples/networks-and-flows/graph/graph-custom-icons/index.tsx
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,68 @@ | ||
import React from 'react' | ||
import { VisSingleContainer, VisGraph } from '@unovis/react' | ||
import { NodeDatum } from '@src/utils/data' | ||
|
||
import personIcon from './person.svg?raw' | ||
import roleIcon from './role.svg?raw' | ||
import instanceIcon from './instance.svg?raw' | ||
import bucketIcon from './bucket.svg?raw' | ||
|
||
import s from './index.module.css' | ||
|
||
export const title = 'Graph: SVG Node Icons' | ||
export const subTitle = 'cured links, long labels' | ||
|
||
export const component = (): JSX.Element => { | ||
const svgDefs = ` | ||
${personIcon} | ||
${roleIcon} | ||
${instanceIcon} | ||
${bucketIcon} | ||
` | ||
|
||
const nodes = [ | ||
{ id: '[email protected]', icon: '#personIcon', fillColor: '#DFFAFD', label: 'External User', sublabel: '[email protected]' }, | ||
{ id: 'AWSReservedSSO_Something', icon: '#roleIcon', fillColor: '#E3DEFC', label: 'Role', sublabel: 'AWSReservedSSO_Something' }, | ||
{ id: 'i-0a1b2c3d4e5f6g7h8', icon: '#instanceIcon', fillColor: '#D0E1FC', label: 'EC2 Instance', sublabel: 'i-0a1b2c3d4e5f6g7h8' }, | ||
{ id: 'i-1a1b2c3d4e5f6g7h8', icon: '#instanceIcon', fillColor: '#D0E1FC', label: 'EC2 Instance', sublabel: 'i-1a1b2c3d4e5f6g7h8' }, | ||
{ id: 'my-bucket', icon: '#bucketIcon', fillColor: '#D4DBFB', label: 'S3 Bucket', sublabel: 'my-bucket' }, | ||
{ id: 'tests-ansible-ssm-file-transfer', icon: '#bucketIcon', fillColor: '#D4DBFB', label: 'S3 Bucket', sublabel: 'tests-ansible-ssm-file-transfer' }, | ||
] | ||
|
||
const links = [ | ||
{ source: 0, target: 1, label: { text: 'assume' } }, | ||
{ source: 1, target: 2, label: { text: '1' } }, | ||
{ source: 1, target: 3, label: { text: 'label' } }, | ||
{ source: 1, target: 4 }, | ||
{ source: 1, target: 5, label: { text: '2' } }, | ||
] | ||
|
||
const data = { nodes, links } | ||
return ( | ||
<div className={s.graph}> | ||
<VisSingleContainer svgDefs={svgDefs} height={600}> | ||
<VisGraph | ||
data={data} | ||
nodeIcon={(n: NodeDatum) => n.icon} | ||
nodeIconSize={18} | ||
nodeStroke={'none'} | ||
nodeFill={(n: NodeDatum) => n.fillColor} | ||
nodeLabel={(n: NodeDatum) => n.label} | ||
nodeSubLabel={(n: NodeDatum) => n.sublabel} | ||
layoutType='dagre' | ||
dagreLayoutSettings={{ | ||
rankdir: 'LR', | ||
ranksep: 120, | ||
nodesep: 20, | ||
}} | ||
linkBandWidth={6} | ||
linkFlow={true} | ||
linkCurvature={1} | ||
linkArrow={'single'} | ||
linkLabel={(l: typeof links[0]) => l.label} | ||
/> | ||
</VisSingleContainer> | ||
</div> | ||
) | ||
} | ||
|
5 changes: 5 additions & 0 deletions
5
packages/dev/src/examples/networks-and-flows/graph/graph-custom-icons/instance.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions
10
packages/dev/src/examples/networks-and-flows/graph/graph-custom-icons/person.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/dev/src/examples/networks-and-flows/graph/graph-custom-icons/role.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
|
@@ -48,6 +48,10 @@ module.exports = { | |
}, | ||
], | ||
}, | ||
{ | ||
resourceQuery: /raw/, | ||
type: 'asset/source', | ||
}, | ||
], | ||
}, | ||
resolve: { | ||
|
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