Skip to content

Commit a6aa6fd

Browse files
(updated) variable names in totalRenderArr
1 parent e0050b8 commit a6aa6fd

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

src/app/components/PerformanceVisx.tsx

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import { useTooltip, useTooltipInPortal, defaultStyles } from "@visx/tooltip";
99
// import { LegendOrdinal } from "@visx/legend";
1010
import { schemeSet1,schemeSet3 } from "d3-scale-chromatic";
1111
// import snapshots from "./snapshots";
12+
import useForceUpdate from './useForceUpdate';
1213

1314

1415
/* TYPESCRIPT */
15-
type CityName = "New York" | "San Francisco" | "Austin";
1616
type snapshot = any;
1717
type TooltipData = {
1818
bar: SeriesPoint<snapshot>;
@@ -98,26 +98,23 @@ export default function PerformanceVisx({
9898
showTooltip
9999
} = useTooltip<TooltipData>();
100100

101-
/* DATA PREP */
102-
// const data = getPerfMetrics(snapshots);
103-
const data = getPerfMetrics(snapshots, getSnapshotIds(hierarchy))
104-
console.log(data)
105-
106-
// array of all object keys
101+
// data prep
102+
const data = getPerfMetrics(snapshots, getSnapshotIds(hierarchy))
107103
const keys = Object.keys(data[0]).filter((d) => d !== "snapshotId") as CityName[];
104+
console.log(data)
108105

109106
// ARRAY OF TOTAL VALUES PER SNAPSHOT
110-
const temperatureTotals = data.reduce((allTotals, currentDate) => {
111-
const totalTemperature = keys.reduce((dailyTotal, k) => {
112-
dailyTotal += Number(currentDate[k]);
113-
return dailyTotal;
107+
const totalRenderArr = data.reduce((totalRender, curSnapshot) => {
108+
const curRenderTotal = keys.reduce((acc, cur) => {
109+
acc += Number(curSnapshot[cur]);
110+
return acc;
114111
}, 0);
115-
allTotals.push(totalTemperature);
116-
return allTotals;
112+
totalRender.push(curRenderTotal);
113+
return totalRender;
117114
}, [] as number[]);
118115

119116
const temperatureScale = scaleLinear<number>({
120-
domain: [0, Math.max(...temperatureTotals)],
117+
domain: [0, Math.max(...totalRenderArr)],
121118
nice: true
122119
});
123120
const colorScale = scaleOrdinal<CityName, string>({

0 commit comments

Comments
 (0)