-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(summary): SJIP-1093 add co-occuring conditions graph
- Loading branch information
lflangis
committed
Nov 29, 2024
1 parent
1ac8fd3
commit 58f72c5
Showing
8 changed files
with
38,397 additions
and
88 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
44 changes: 44 additions & 0 deletions
44
...DataExploration/components/PageContent/tabs/Summary/CoOccuringConditions/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,44 @@ | ||
.wrapper { | ||
height: 100%; | ||
position: relative; | ||
width: 100%; | ||
text-align: center; | ||
} | ||
|
||
.wrapper .content { | ||
position: absolute; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
:global([class^="root-upset-"] text[class^="setTextStyle-upset"]) { | ||
font-size: 12px; | ||
width: 10px; | ||
} | ||
|
||
:global([class^="root-upset-"] text[class^="hoverBarTextStyle-upset"]) { | ||
fill: var(--gray-7); | ||
} | ||
|
||
:global([class^="root-upset-"] [class^="interactive-upset"]):hover > [class^="hoverBar-upset"] { | ||
stroke: var(--gray-7); | ||
} | ||
|
||
:global([class^="root-upset-"] [class^="upsetLine-upset"]), | ||
:global([class^="root-upset-"] [class^="upsetSelectionLine-upset"]), | ||
:global([class^="root-upset-"] [class^="fillPrimary-upset"]) { | ||
fill: var(--blue-7); | ||
stroke: var(--blue-7); | ||
} | ||
|
||
:global([class^="root-upset-"] [class^="fillSelection-upset"]) { | ||
fill: var(--gold-6); | ||
} | ||
|
||
:global([class^="root-upset-"] [class^="fillAlternating-upset"]) { | ||
fill: var(--gray-4); | ||
} | ||
|
||
:global([class^="root-upset-"] [class^="fillNotMember-upset"]) { | ||
fill: var(--gray-5); | ||
} |
91 changes: 91 additions & 0 deletions
91
src/views/DataExploration/components/PageContent/tabs/Summary/CoOccuringConditions/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,91 @@ | ||
import { useEffect, useMemo, useRef, useState } from 'react'; | ||
import intl from 'react-intl-universal'; | ||
import ResizableGridCard from '@ferlab/ui/core/layout/ResizableGridLayout/ResizableGridCard'; | ||
import { extractCombinations, ISetLike, UpSetJS } from '@upsetjs/react'; | ||
|
||
import { getResizableGridDictionary } from 'utils/translation'; | ||
|
||
import { UID } from '../utils/grid'; | ||
|
||
import mock from './mock'; | ||
|
||
import styles from './index.module.css'; | ||
|
||
// https://upset.js.org/api/model/modules.html | ||
const CoOccuringConditionsGraphCard = () => { | ||
const ref = useRef<any>(null); | ||
const [width, setWidth] = useState<number>(100); | ||
const [height, setHeight] = useState<number>(100); | ||
const [selection, setSelection] = useState<ISetLike<unknown> | null>(null); | ||
|
||
const data = mock | ||
.map((m) => { | ||
const combination = m.Combination.split(', '); | ||
return { | ||
name: m.Combination, | ||
sets: combination, | ||
}; | ||
}) | ||
.filter((m) => m.sets.length > 1); | ||
|
||
const { sets, combinations } = useMemo( | ||
() => | ||
extractCombinations(data, { | ||
setLimit: 8, | ||
}), | ||
[], | ||
); | ||
|
||
useEffect(() => { | ||
const observer = new ResizeObserver((entries) => { | ||
setWidth(entries[0].contentRect.width); | ||
setHeight(entries[0].contentRect.height); | ||
}); | ||
observer.observe(ref.current); | ||
return () => ref.current && observer.unobserve(ref.current); | ||
}, []); | ||
|
||
useEffect(() => { | ||
const elements = document.querySelectorAll( | ||
'[class^="root-upset-"] text[class^="setTextStyle-upset"]', | ||
); | ||
elements.forEach((element: any) => { | ||
element.textContent = element.textContent.substring(0, 28) + '…'; | ||
}); | ||
}, []); | ||
|
||
return ( | ||
<ResizableGridCard | ||
gridUID={UID} | ||
id="co-occurring-conditions" | ||
theme="shade" | ||
loading={false} | ||
loadingType="spinner" | ||
dictionary={getResizableGridDictionary()} | ||
headerTitle={intl.get('screen.dataExploration.tabs.summary.coOccuringConditions.title')} | ||
content={ | ||
<div className={styles.wrapper}> | ||
<div ref={ref} className={styles.content}> | ||
<UpSetJS | ||
setLabelAlignment={'left'} | ||
sets={sets} | ||
setName={intl.get('screen.dataExploration.tabs.summary.coOccuringConditions.label')} | ||
combinationName={intl.get( | ||
'screen.dataExploration.tabs.summary.coOccuringConditions.label', | ||
)} | ||
exportButtons={false} | ||
selection={selection} | ||
combinations={combinations} | ||
emptySelection={false} | ||
width={width} | ||
height={height} | ||
onHover={(s) => setSelection(s)} | ||
/> | ||
</div> | ||
</div> | ||
} | ||
/> | ||
); | ||
}; | ||
|
||
export default CoOccuringConditionsGraphCard; |
Oops, something went wrong.