Skip to content

Commit

Permalink
feat(sunBurst): kids-first#2643 incorporate comments
Browse files Browse the repository at this point in the history
  • Loading branch information
adipaul1981 committed Nov 30, 2020
1 parent 89cf02d commit 08ffb6b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
11 changes: 6 additions & 5 deletions src/components/UI/Charts/Sunburst/InfoPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { AddTermToActiveIndex, Term } from 'store/virtualStudiesTypes';
import { Button, Tree } from 'antd';
import { TreeNode } from 'components/OntologyBrowser/Model';
import './sunburst.css';
import { RegexExtractPhenotype } from '../../../OntologyBrowser/store';
import { RegexExtractPhenotype } from 'components/OntologyBrowser/store';

type OwnProps = {
data: Pick<Phenotype, 'title' | 'key' | 'results' | 'exactTagCount'>;
Expand All @@ -35,13 +35,14 @@ const splitTitle = (title: string) => {
};
};

export const getPath = (node: string, treeNodes: TreeNode[], path: string[] = []) => {
export const getPath = (node: string, treeNodes: TreeNode[], path: string[] = []): string[] => {
const updatePath = [...path];
const currentNodeText = treeNodes[0].key;
path.push(currentNodeText);
updatePath.push(currentNodeText);
if (node !== currentNodeText) {
getPath(node, treeNodes[0].children, path);
return getPath(node, treeNodes[0].children, updatePath);
}
return path;
return updatePath;
};

const generateNodeIdClicked = (
Expand Down
2 changes: 1 addition & 1 deletion src/components/UI/Charts/Sunburst/Sunburst.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class Sunburst extends Component<SunburstProps, State> {
/>
<div className={'grid-item'}>
<InfoPanel
data={{ ...selectedPhenotypeInfo }}
data={selectedPhenotypeInfo}
treeData={phenotypeTree}
getSelectedPhenotype={this.getSelectedPhenotypeFromTree}
/>
Expand Down
23 changes: 13 additions & 10 deletions src/components/UI/Charts/Sunburst/sunburst-d3.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,16 +267,19 @@ const sunburstD3 = (ref, data, config, getSelectedPhenotype, formatters) => {
};

const findNodeByKey = (key, node, returnNode) => {
if (returnNode) return returnNode;
node.children.forEach((n) => {
if (key.includes(n.data.name)) {
if (key === n.data.key) {
returnNode = n;
} else {
returnNode = findNodeByKey(key, n, returnNode);
}
}
});
if (returnNode) {
return returnNode;
}
const findNode = node.children.find((n) => key.includes(n.data.name));
if (!findNode) {
return returnNode;
}

if (findNode && key === findNode.data.key) {
returnNode = findNode;
} else {
returnNode = findNodeByKey(key, findNode, returnNode);
}
return returnNode;
};

Expand Down

0 comments on commit 08ffb6b

Please sign in to comment.