Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/graph view widget #155

Merged
merged 22 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f2af8e2
feat: added GraphViewWidget.
Pooya-Oladazimi Oct 16, 2024
23df6c2
Merge branch 'main' into feat/graph-view-widget
Pooya-Oladazimi Oct 18, 2024
35336d3
refactor(GraphViewWidget): move the types to the types.ts
Pooya-Oladazimi Oct 18, 2024
0b4c9a8
handle loading and error cased in the graphView widget.
Pooya-Oladazimi Oct 18, 2024
1e94f50
feat(GraphViewWidget): added graph action for node expansion and
Pooya-Oladazimi Oct 18, 2024
4dafc52
added hint text for the GraphView widget.
Pooya-Oladazimi Oct 18, 2024
22d3436
feat(GraphViewWidget): added "walk from root term" feature to show the
Pooya-Oladazimi Oct 21, 2024
35f0fd8
fix the issue with node double clicked in rootwalk mode.
Pooya-Oladazimi Oct 22, 2024
643e448
fix the issue with graph re-render when toggling the rootWalk boolean
Pooya-Oladazimi Oct 22, 2024
1a3cf7e
build(GraphViewWidget): built plainJS.
Pooya-Oladazimi Oct 22, 2024
7deb746
added chebi water story for graph view
Pooya-Oladazimi Oct 22, 2024
c2f0de1
use jsTree endpoint in ols instead of ancestors for graph view root walk
Pooya-Oladazimi Oct 22, 2024
8edcd88
styling the graphViewWidget
Pooya-Oladazimi Oct 23, 2024
18a288d
implemented the rootWalk switch for the graphViewWidget.
Pooya-Oladazimi Oct 23, 2024
f717718
fix the issue with not updating the graph on input props change.
Pooya-Oladazimi Oct 23, 2024
b630b64
added documentation and build html for graphView widget.
Pooya-Oladazimi Oct 23, 2024
49bb0ce
highlight the target node in graph root walk mode.
Pooya-Oladazimi Oct 24, 2024
74f48c1
use elastic ui popover for the graphView hint text.
Pooya-Oladazimi Oct 24, 2024
b1c780d
build(GraphViewWidget): build plain js.
Pooya-Oladazimi Oct 24, 2024
962a69f
fix a typo in graphView widget.
Pooya-Oladazimi Oct 24, 2024
966245b
added new stories for chebi in graphView widget.
Pooya-Oladazimi Oct 28, 2024
2b8bacd
change the non subclassof edges to dashed on normal graph mode.
Pooya-Oladazimi Oct 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 37 additions & 21 deletions src/components/widgets/GraphViewWidget/GraphViewWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ReactDOM from "react-dom";
import { GraphViewWidgetProps } from "../../../app/types";
import { OlsApi } from "../../../api/OlsApi";
import { useQuery, QueryClient, QueryClientProvider } from "react-query";
import { EuiProvider, EuiLoadingSpinner, EuiText, EuiButton, EuiIcon, EuiPanel,EuiSwitch } from "@elastic/eui";
import { EuiProvider, EuiLoadingSpinner, EuiText, EuiButton, EuiIcon, EuiPanel,EuiSwitch, EuiPopover, EuiButtonEmpty } from "@elastic/eui";
import { Network } from 'vis-network';
import { DataSet } from 'vis-data';
import { OlsGraphNode, OlsGraphEdge } from "../../../app/types";
Expand All @@ -21,6 +21,7 @@ function GraphViewWidget(props: GraphViewWidgetProps) {
const [firstLoad, setFirstLoad] = useState(true);
const [dbclicked, setDbclicked] = useState(false);
const [rootWalkIsSelected, setRootWalkIsSelected] = useState(rootWalk ? rootWalk : false);
const [isPopoverOpen, setIsPopoverOpen] = useState(false);

// needed for useQuery. without it the graph won't get updated on switching berween rootWalk=true and false.
const [counter, setCounter] = useState(0);
Expand Down Expand Up @@ -257,33 +258,48 @@ function GraphViewWidget(props: GraphViewWidgetProps) {
}, [rootWalk]);


const hintText = `
- You can expand the nodes by double clicking on them.\n
- You can zoom out/in by scrolling on the graph. \n
- You can go back to the initial graph by clicking on the Reset button. \n
- You can move the nodes and edges around by dragging. \n
- Rootwalk toggle enable the root walk mode in the graph, where you can see the path from roots to the target node. \n
`;

const onButtonClick = () =>
setIsPopoverOpen((isPopoverOpen) => !isPopoverOpen);
const closePopover = () => setIsPopoverOpen(false);

const button = (
<EuiButtonEmpty
iconType="iInCircle"
iconSide="right"
onClick={onButtonClick}
>
Guid me
jusa3 marked this conversation as resolved.
Show resolved Hide resolved
</EuiButtonEmpty>
);


return (
<>
{isError && <EuiText>{getErrorMessageToDisplay(error, "graph")}</EuiText>}
<EuiPanel style={{ fontSize: 12 }} paddingSize='s' borderRadius="none">
<EuiButton size="s" onClick={reset}>Reset</EuiButton>
<EuiIcon
type={"iInCircle"}
style={{ marginLeft: 5 }}
size="l"
title={hintText}
/>
<div style={{display: 'inline-block', float: 'right'}}>
<EuiSwitch
label="root walk"
checked={rootWalkIsSelected}
onChange={() => {setRootWalkIsSelected(!rootWalkIsSelected)}}
title="Enable the root walk mode in the graph: You can see the path from roots to the target node"
/></div>
<EuiPopover
button={button}
isOpen={isPopoverOpen}
closePopover={closePopover}
>
<EuiText style={{ width: 300, padding: 10 }}>
<li>You can expand the nodes by double clicking on them</li>
<li>You can zoom out/in by scrolling on the graph.</li>
<li>You can go back to the initial graph by clicking on the Reset button.</li>
<li>You can move the nodes and edges around by dragging.</li>
<li>Rootwalk toggle enable the root walk mode in the graph, where you can see the path from roots to the target node.</li>
</EuiText>
</EuiPopover>
<div style={{display: 'inline-block', float: 'right', paddingTop: 10}}>
<EuiSwitch
label="root walk"
checked={rootWalkIsSelected}
onChange={() => {setRootWalkIsSelected(!rootWalkIsSelected)}}
title="Enable the root walk mode in the graph: You can see the path from roots to the target node"
/>
</div>
</EuiPanel>

<EuiPanel style={{ width: 900, height: 900 }} hasShadow={false} hasBorder={true} borderRadius="none" >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ export const ChebiExample = {
iri: "http://purl.obolibrary.org/obo/CHEBI_15377",
ontologyId: "chebi",
useLegacy: true,
rootWalk: false
rootWalk: true
}
}
Loading