-
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.
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
- Loading branch information
1 parent
0ea45b5
commit 4a86104
Showing
9 changed files
with
99 additions
and
97 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
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 |
---|---|---|
@@ -1,69 +1,84 @@ | ||
import React from "react"; | ||
import './graph.css' | ||
import {Options} from "react-vis-graph-wrapper"; | ||
|
||
import "./graph.css"; | ||
import { Options } from "react-vis-graph-wrapper"; | ||
|
||
interface GraphOptionsControlPanelProps { | ||
options: Options; | ||
setOptions: React.Dispatch<React.SetStateAction<Options>>; | ||
|
||
options: Options; | ||
setOptions: React.Dispatch<React.SetStateAction<Options>>; | ||
} | ||
|
||
function getSmoothEnabled(options: Options): boolean { | ||
if (typeof options.edges?.smooth === 'boolean') { | ||
return options.edges.smooth; | ||
} else if (typeof options.edges?.smooth === 'object' && 'enabled' in options.edges.smooth) { | ||
return options.edges.smooth.enabled; | ||
} else { | ||
return false; | ||
} | ||
if (typeof options.edges?.smooth === "boolean") { | ||
return options.edges.smooth; | ||
} else if ( | ||
typeof options.edges?.smooth === "object" && | ||
"enabled" in options.edges.smooth | ||
) { | ||
return options.edges.smooth.enabled; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
export const GraphOptionsControlPanel = ({options, setOptions}: GraphOptionsControlPanelProps) => { | ||
|
||
|
||
return <div className={"flex-container"}> | ||
<div className={"flex-container__element"}> | ||
Physics enabled: | ||
<input type={"checkbox"} checked={options.physics.enabled} | ||
onChange={(event) => setOptions( | ||
{ | ||
...options, | ||
physics: { | ||
...options.physics, | ||
enabled: event.target.checked | ||
} | ||
}) | ||
}/> | ||
</div> | ||
<div className={"flex-container__element"}> | ||
Rounded edges: | ||
<input type={"checkbox"} checked={getSmoothEnabled(options)} | ||
onChange={(event) => setOptions( | ||
{ | ||
...options, | ||
edges: { | ||
...options.edges, | ||
smooth: !options.edges?.smooth | ||
} | ||
}) | ||
}/> | ||
</div> | ||
<div className={"flex-container__element"}> | ||
Edge length: | ||
<input type="range" min="50" max="1000" value={options.physics.barnesHut.springLength} | ||
onChange={(event) => setOptions( | ||
{ | ||
...options, | ||
physics: { | ||
...options.physics, | ||
barnesHut: { | ||
springLength: Number(event.target.value) | ||
} | ||
} | ||
}) | ||
} | ||
step="1"/> | ||
</div> | ||
export const GraphOptionsControlPanel = ({ | ||
options, | ||
setOptions, | ||
}: GraphOptionsControlPanelProps) => { | ||
return ( | ||
<div className={"flex-container"}> | ||
<div className={"flex-container__element"}> | ||
Physics enabled: | ||
<input | ||
type={"checkbox"} | ||
checked={options.physics.enabled} | ||
onChange={(event) => | ||
setOptions({ | ||
...options, | ||
physics: { | ||
...options.physics, | ||
enabled: event.target.checked, | ||
}, | ||
}) | ||
} | ||
/> | ||
</div> | ||
<div className={"flex-container__element"}> | ||
Rounded edges: | ||
<input | ||
type={"checkbox"} | ||
checked={getSmoothEnabled(options)} | ||
onChange={(event) => | ||
setOptions({ | ||
...options, | ||
edges: { | ||
...options.edges, | ||
smooth: !options.edges?.smooth, | ||
}, | ||
}) | ||
} | ||
/> | ||
</div> | ||
<div className={"flex-container__element"}> | ||
Edge length: | ||
<input | ||
type="range" | ||
min="50" | ||
max="1000" | ||
value={options.physics.barnesHut.springLength} | ||
onChange={(event) => | ||
setOptions({ | ||
...options, | ||
physics: { | ||
...options.physics, | ||
barnesHut: { | ||
springLength: Number(event.target.value), | ||
}, | ||
}, | ||
}) | ||
} | ||
step="1" | ||
/> | ||
</div> | ||
</div> | ||
} | ||
); | ||
}; |
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
body { | ||
margin: 0; | ||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', | ||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', | ||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", | ||
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", | ||
sans-serif; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
} | ||
|
||
code { | ||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', | ||
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", | ||
monospace; | ||
} |
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