Skip to content

Commit 8b092ea

Browse files
committed
clean legend element
1 parent e84b635 commit 8b092ea

File tree

2 files changed

+50
-56
lines changed

2 files changed

+50
-56
lines changed

src/app/components/StateRoute.tsx

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import AtomsRelationship from './AtomsRelationship.jsx';
1818
import Example from './AtomsRelationship.jsx';
1919
import { ParentSize } from '@visx/responsive';
2020
import { Console } from 'console';
21-
// import { History } from './History';
2221
import Legendary from './legend';
2322

2423
const History = require('./History').default;
@@ -61,21 +60,14 @@ const StateRoute = (props: StateRouteProps) => {
6160
const renderComponentMap = () => {
6261
if (hierarchy) {
6362
return (
64-
<div>
65-
<div>
66-
<Legendary hierarchy={hierarchy} />
67-
</div>
68-
<div>
69-
<ComponentMap
70-
viewIndex={viewIndex}
71-
snapshots={snapshots}
72-
x={x}
73-
y={y}
74-
k={k}
75-
setZoomState={setZoomState}
76-
/>
77-
</div>
78-
</div>
63+
<ComponentMap
64+
viewIndex={viewIndex}
65+
snapshots={snapshots}
66+
x={x}
67+
y={y}
68+
k={k}
69+
setZoomState={setZoomState}
70+
/>
7971
);
8072
}
8173
return <div className="noState">{NO_STATE_MSG}</div>;

src/app/components/legend.tsx

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,47 @@ const ordinalColorScale = scaleOrdinal<number, string>({
99
range: ['#66d981', '#71f5ef', '#4899f1', '#7d81f6'],
1010
});
1111

12-
const displayArray = (obj: {
13-
stateSnapshot: { children: any[] };
14-
name: number;
15-
branch: number;
16-
index: number;
17-
children?: [];
18-
}) => {
19-
if (
20-
obj.stateSnapshot.children.length > 0 &&
21-
obj.stateSnapshot.children[0] &&
22-
obj.stateSnapshot.children[0].state &&
23-
obj.stateSnapshot.children[0].name
24-
) {
25-
const newObj: Record<string, unknown> = {
26-
index: obj.index,
27-
displayName: `${obj.name}.${obj.branch}`,
28-
state: obj.stateSnapshot.children[0].state,
29-
componentName: obj.stateSnapshot.children[0].name,
30-
componentData:
31-
JSON.stringify(obj.stateSnapshot.children[0].componentData) === '{}'
32-
? ''
33-
: obj.stateSnapshot.children[0].componentData,
34-
};
35-
hierarchyArr.push(newObj);
36-
}
37-
if (obj.children) {
38-
obj.children.forEach((element) => {
39-
displayArray(element);
40-
});
41-
}
42-
};
43-
// the hierarchy gets set on the first click in the page
44-
// when page in refreshed we may not have a hierarchy so we need to check if hierarchy was initialized
45-
// if true involk displayArray to display the hierarchy
46-
// if (hierarchy) displayArray(hierarchy);
47-
4812
const legendGlyphSize = 12;
4913

50-
export default function Legendary({ events = false }: { events?: boolean }) {
14+
export default function Legendary(props: any) {
15+
// { events = false }: { events?: boolean }) {
16+
const displayArray = (obj: {
17+
stateSnapshot: { children: any[] };
18+
name: number;
19+
branch: number;
20+
index: number;
21+
children?: [];
22+
}) => {
23+
if (
24+
obj.stateSnapshot.children.length > 0 &&
25+
obj.stateSnapshot.children[0] &&
26+
obj.stateSnapshot.children[0].state &&
27+
obj.stateSnapshot.children[0].name
28+
) {
29+
const newObj: Record<string, unknown> = {
30+
index: obj.index,
31+
displayName: `${obj.name}.${obj.branch}`,
32+
state: obj.stateSnapshot.children[0].state,
33+
componentName: obj.stateSnapshot.children[0].name,
34+
componentData:
35+
JSON.stringify(obj.stateSnapshot.children[0].componentData) === '{}'
36+
? ''
37+
: obj.stateSnapshot.children[0].componentData,
38+
};
39+
hierarchyArr.push(newObj);
40+
}
41+
if (obj.children) {
42+
obj.children.forEach((element) => {
43+
displayArray(element);
44+
});
45+
}
46+
};
47+
// the hierarchy gets set on the first click in the page
48+
// when page in refreshed we may not have a hierarchy so we need to check if hierarchy was initialized
49+
// if true involk displayArray to display the hierarchy
50+
// if (hierarchy) displayArray(hierarchy);
51+
console.log('Inside Legendary, props is', props);
52+
5153
return (
5254
<div className="legends">
5355
<LegendVisual title="State Snapshots">
@@ -58,9 +60,9 @@ export default function Legendary({ events = false }: { events?: boolean }) {
5860
<LegendItem
5961
key={`legend-quantile-${i}`}
6062
margin="0 5px"
61-
onClick={() => {
62-
if (events) alert(`clicked: ${JSON.stringify(label)}`);
63-
}}
63+
// onClick={() => {
64+
// if (events) alert(`clicked: ${JSON.stringify(label)}`);
65+
// }}
6466
>
6567
<svg width={10} height={10}>
6668
<rect

0 commit comments

Comments
 (0)