Skip to content

Commit

Permalink
replaced hierarchies component with graph prop
Browse files Browse the repository at this point in the history
  • Loading branch information
derwehr committed Jun 1, 2021
1 parent 479f01d commit e685c54
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 119 deletions.
3 changes: 1 addition & 2 deletions frontend/src/routing/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Data from '../data/Data';
import Exploration from '../exploration/Exploration';
import Home from '../home/Home';
import Graph from '../visualization/Graph';
import Hierarchies from '../visualization/Hierarchies';
import Schema from '../visualization/Schema';
import Visualization from '../visualization/Visualization';
import RouteDefinition from './RouteDefinition';
Expand Down Expand Up @@ -34,7 +33,7 @@ const routes: Record<string, RouteDefinition> = {
{
path: '/visualization/hierarchical',
label: 'Hierarchies',
content: () => <Hierarchies />,
content: () => <Graph layout="hierarchical" />,
},
],
},
Expand Down
21 changes: 17 additions & 4 deletions frontend/src/visualization/Graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ const useStyles = makeStyles(() =>
* @param height The height of the graph.
* @returns The react-graph-vis options.
*/
function buildOptions(width: number, height: number) {
function buildOptions(width: number, height: number, layout?: string) {
return {
layout: {
hierarchical: false,
hierarchical: layout === 'hierarchical',
},
edges: {
color: '#000000',
Expand All @@ -62,7 +62,12 @@ function buildOptions(width: number, height: number) {
};
}

function Graph(): JSX.Element {
type GraphProps = {
layout?: string;
};

function Graph(props: GraphProps): JSX.Element {
const { layout } = props;
const classes = useStyles();

// A React ref to the container that is used to measure the available space for the graph.
Expand Down Expand Up @@ -98,7 +103,11 @@ function Graph(): JSX.Element {
<div className={classes.graphContainer}>
<VisGraph
graph={graphData}
options={buildOptions(containerSize.width, containerSize.height)}
options={buildOptions(
containerSize.width,
containerSize.height,
layout
)}
key={uuid()}
/>
</div>
Expand All @@ -110,4 +119,8 @@ function Graph(): JSX.Element {
);
}

Graph.defaultProps = {
layout: undefined,
};

export default Graph;
113 changes: 0 additions & 113 deletions frontend/src/visualization/Hierarchies.tsx

This file was deleted.

0 comments on commit e685c54

Please sign in to comment.