Skip to content

Commit 7e001fc

Browse files
committed
AtomsRelationship loads new state on state change, History better error handeling, styling change
1 parent d1ba94b commit 7e001fc

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

src/app/components/AtomsRelationship.jsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,19 @@ import { Chart } from 'react-google-charts';
1010
function AtomsRelationship(props) {
1111
console.log('Props', props.atomsRel);
1212

13+
const {atomsRel} = props
14+
15+
1316
return (
1417
<div className="history-d3-container">
15-
<Chart
18+
{atomsRel && (
19+
<Chart
1620
width={'100%'}
1721
height={'100%'}
1822
chartType="Sankey"
1923
options={{
2024
sankey: {
21-
link: { color: { fill: '#c6e6f', fillOpacity: 0.1 } },
25+
link: { color: { fill: '#gray', fillOpacity: 0.1 } },
2226
node: {
2327
colors: [
2428
'#4a91c7',
@@ -31,18 +35,23 @@ function AtomsRelationship(props) {
3135
'#b7dbf8',
3236
'#c6e6ff',
3337
'#46edf2',
38+
'#76f5f3',
3439
'#95B6B7',
40+
'#76dcde',
41+
'#5fdaed',
3542
],
43+
3644
label: { color: '#fff', fontSize: '14' },
3745
nodePadding: 50,
3846
width: 15,
3947
},
4048
},
49+
tooltip: { textStyle: { color: 'gray', fontSize: 12 }},
4150
}}
4251
loader={<div>Loading Chart</div>}
43-
data={[['Atom', 'Selector', ''], ...props.atomsRel]}
52+
data={[['Atom', 'Selector', ''], ...atomsRel]}
4453
rootProps={{ 'data-testid': '1' }}
45-
/>
54+
/>)}
4655
</div>
4756
);
4857
}

src/app/components/History.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ const filterHooks = (data: any[]) => {
3030
return JSON.stringify(data[0].state);
3131
};
3232

33-
interface HistoryProps {
34-
hierarchy: Record<string, unknown>;
35-
}
36-
3733

3834
/**
3935
* @method maked3Tree :Creates a new D3 Tree
@@ -44,7 +40,6 @@ function History(props) {
4440
let root = JSON.parse(JSON.stringify(hierarchy));
4541
let isRecoil = false;
4642
let HistoryRef = React.createRef(root); //React.createRef(root);
47-
4843
useEffect(() => {
4944
maked3Tree();
5045
}, [root]);

src/app/components/StateRoute.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ interface StateRouteProps {
3232
children?: any[];
3333
AtomsRelationship?: any[];
3434
};
35-
hierarchy: object;
35+
hierarchy: any;
3636
snapshots: [];
3737
viewIndex: number;
3838
}
@@ -44,6 +44,8 @@ const StateRoute = (props: StateRouteProps) => {
4444
// console.log(snapshot.AtomsRelationship)
4545
let isRecoil = snapshot.AtomsRelationship ? true : false;
4646
const [noRenderData, setNoRenderData] = useState(false);
47+
48+
// component map zoom state
4749
const [{ x, y, k }, setZoomState]: any = useState({
4850
x: 150,
4951
y: 250,
@@ -63,10 +65,11 @@ const StateRoute = (props: StateRouteProps) => {
6365
// when the page is refreshed we may not have a hierarchy, so we need to check if hierarchy was initialized
6466
// if true involk render chart with hierarchy
6567
const renderHistory = () => {
66-
if (hierarchy) {
68+
if (hierarchy.children.length > 0) {
69+
6770
return <History hierarchy={hierarchy} />;
6871
}
69-
return <div className="noState">{NO_STATE_MSG}</div>;
72+
return <div className="noState">Application not compatible with history</div>;
7073
};
7174

7275
const renderAtomsRelationship = () => {

0 commit comments

Comments
 (0)