Skip to content

Commit dba8cb1

Browse files
(updated) traversal algo to skip children with no rendering time, implemented chromatic scale, verified snapshotID displays
1 parent 0e6beb1 commit dba8cb1

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/app/components/PerformanceVisx.tsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,15 @@ const getPerfMetrics = (snapshots, snapshotsIds) => {
5555
}, [])
5656
}
5757

58-
const traverse = (snapshot, perfSnapshot = {}) => {
59-
if (!snapshot.children[0]) return;
60-
perfSnapshot[snapshot.name] = snapshot.componentData.actualDuration;
58+
const traverse = (snapshot, perfSnapshot) => {
59+
if (!snapshot.children[0]) return
6160
for (let i = 0; i < snapshot.children.length; i++){
62-
perfSnapshot[snapshot.children[i].name+i] = snapshot.children[i].componentData.actualDuration;
63-
traverse(snapshot.children[i], perfSnapshot);
61+
if (snapshot.children[i].componentData.actualDuration){
62+
perfSnapshot[snapshot.children[i].name+i] = snapshot.children[i].componentData.actualDuration
63+
}
64+
traverse(snapshot.children[i], perfSnapshot)
6465
}
65-
return perfSnapshot;
66+
return perfSnapshot
6667
}
6768

6869
const getSnapshotIds = (obj, snapshotIds = []) => {
@@ -97,11 +98,11 @@ export default function PerformanceVisx({
9798

9899
/* DATA PREP */
99100
// const data = getPerfMetrics(snapshots);
100-
const data = [...snapshots]
101-
console.log('cleaned data', getPerfMetrics(snapshots, getSnapshotIds(hierarchy)))
101+
const data = getPerfMetrics(snapshots, getSnapshotIds(hierarchy))
102+
console.log(data)
102103

103104
// array of all object keys
104-
const keys = Object.keys(data[0]).filter((d) => d !== "snapshot") as CityName[];
105+
const keys = Object.keys(data[0]).filter((d) => d !== "snapshotId") as CityName[];
105106

106107
// ARRAY OF TOTAL VALUES PER SNAPSHOT
107108
const temperatureTotals = data.reduce((allTotals, currentDate) => {
@@ -119,14 +120,14 @@ const temperatureScale = scaleLinear<number>({
119120
});
120121
const colorScale = scaleOrdinal<CityName, string>({
121122
domain: keys,
122-
range: [purple1, purple2, purple3, purple4]
123+
range: schemeSet1
123124
});
124125

125126
let tooltipTimeout: number;
126127

127128

128129
/* ACCESSORS */
129-
const getSnapshot = (d: snapshot) => d.snapshot;
130+
const getSnapshot = (d: snapshot) => d.snapshotId;
130131

131132
/* SCALE */
132133
const dateScale = scaleBand<string>({

0 commit comments

Comments
 (0)