Skip to content

Commit eb33407

Browse files
authored
Merge pull request #30 from oslabs-beta/feature/garrett
Feature/garrett
2 parents f201e3d + 18b0574 commit eb33407

File tree

20 files changed

+297
-140
lines changed

20 files changed

+297
-140
lines changed

src/app/components/StateRoute/AxMap/Ax.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import { toggleExpanded, setCurrentTabInApp } from '../../../slices/mainSlice';
1313

1414
const defaultMargin = {
1515
top: 30,
16-
left: 30,
17-
right: 55,
18-
bottom: 70,
16+
left: 20,
17+
right: 50,
18+
bottom: 20,
1919
};
2020

2121
const nodeCoords: object = {};
@@ -71,6 +71,7 @@ export default function AxTree(props) {
7171
borderRadius: '8px',
7272
overflowY: 'auto',
7373
overflowX: 'auto',
74+
backgroundColor: 'transparent',
7475
};
7576

7677
const [orientation, setOrientation] = useState('horizontal');
@@ -93,7 +94,6 @@ export default function AxTree(props) {
9394
sizeHeight = innerWidth;
9495
}
9596

96-
9797
const LinkComponent = getLinkComponent({ linkType, orientation });
9898

9999
const currAxSnapshot = JSON.parse(JSON.stringify(axSnapshots[currLocation.index]));

src/app/components/StateRoute/ComponentMap/ComponentMap.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ const veryHeavy = '#475569'; // Darker gray for medium load
3232
const defaultMargin: DefaultMargin = {
3333
top: 30,
3434
left: 20,
35-
right: 20,
36-
bottom: 70,
35+
right: 50,
36+
bottom: 20,
3737
};
3838

3939
const nodeCoords: object = {};
@@ -124,6 +124,7 @@ export default function ComponentMap({
124124
padding: 0,
125125
borderRadius: '8px',
126126
overflowY: 'auto',
127+
backgroundColor: 'transparent',
127128
};
128129

129130
const nodeList: [] = []; // create a nodeList array to store our nodes as a flat array

src/app/components/StateRoute/History.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable react-hooks/exhaustive-deps */
22
/* eslint-disable */
33
// @ts-nocheck
4-
import React, { useEffect } from 'react';
4+
import React, { useEffect, useRef } from 'react';
55
// formatting findDiff return data to show the changes with colors, aligns with actions.tsx
66
import { diff, formatters } from 'jsondiffpatch';
77
import * as d3 from 'd3';
@@ -41,6 +41,8 @@ function History(props: Record<string, unknown>): JSX.Element {
4141

4242
const svgRef = React.useRef(null);
4343
const root = JSON.parse(JSON.stringify(hierarchy));
44+
const historyEndRef = useRef<HTMLDivElement>(null);
45+
4446
// setting the margins for the Map to render in the tab window.
4547
const innerWidth: number = totalWidth - margin.left - margin.right;
4648
const innerHeight: number = totalHeight - margin.top - margin.bottom - 60;
@@ -239,21 +241,26 @@ function History(props: Record<string, unknown>): JSX.Element {
239241
.style('padding-left', '8px')
240242
.html((d) => findDiff(d.data.index));
241243

244+
if (historyEndRef.current) {
245+
historyEndRef.current.scrollIntoView({ behavior: 'smooth' });
246+
}
242247
return svg.node();
243248
};
244249

245250
useEffect(() => {
246251
makeD3Tree();
247-
}, [root /*, currLocation*/]); // if the 'root' or 'currLocation' changes, re-build the D3 Tree
252+
}, [root, currLocation]);
248253

249254
useEffect(() => {
250255
dispatch(setCurrentTabInApp('history')); // dispatch sent at initial page load allowing changing "immer's" draft.currentTabInApp to 'webmetrics' to facilitate render.
251256
}, []);
252257

253-
// then rendering each node in History tab to render using D3, which will share area with LegendKey
254258
return (
255-
<div className='display'>
256-
<svg ref={svgRef} width={totalWidth} height={totalHeight} />
259+
<div className='history-view'>
260+
<div className='display'>
261+
<svg ref={svgRef} width={totalWidth} height={totalHeight} />
262+
<div ref={historyEndRef} className='history-end-anchor' />
263+
</div>
257264
</div>
258265
);
259266
}

src/app/components/StateRoute/PerformanceVisx/BarGraph.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ const BarGraph = (props: BarGraphProps): JSX.Element => {
111111
// setting max dimensions and scale ranges
112112
const xMax = width - margin.left - margin.right;
113113
snapshotIdScale.rangeRound([0, xMax]);
114-
const yMax = height - margin.top - 150;
114+
const yMax = height - margin.top - 100;
115115
renderingScale.range([yMax, 0]);
116116

117117
const toStorage = {
@@ -127,7 +127,7 @@ const BarGraph = (props: BarGraphProps): JSX.Element => {
127127
<label id='routes-dropdown'>Route: </label>
128128
<select
129129
className='performance-dropdown'
130-
labelId='demo-simple-select-label'
130+
labelid='demo-simple-select-label'
131131
id='routes-select'
132132
onChange={(e) => {
133133
setRoute(e.target.value);
@@ -147,7 +147,7 @@ const BarGraph = (props: BarGraphProps): JSX.Element => {
147147
<form className='routesForm' id='routes-formcontrol'>
148148
<label id='routes-dropdown'>Snapshot: </label>
149149
<select
150-
labelId='demo-simple-select-label'
150+
labelid='demo-simple-select-label'
151151
id='snapshot-select'
152152
onChange={(e) => setSnapshot(e.target.value)}
153153
>

src/app/components/StateRoute/StateRoute.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,21 @@ const StateRoute = (props: StateRouteProps) => {
6161
</NavLink>
6262
<NavLink
6363
className={(navData) =>
64-
navData.isActive ? 'is-active router-link performance' : 'router-link performance-tab'
64+
navData.isActive ? 'is-active router-link history-tab' : 'router-link history-tab'
6565
}
66-
to='/performance'
66+
to='/history'
6767
>
68-
Performance
68+
History
6969
</NavLink>
7070
<NavLink
7171
className={(navData) =>
72-
navData.isActive ? 'is-active router-link history-tab' : 'router-link history-tab'
72+
navData.isActive ? 'is-active router-link performance' : 'router-link performance-tab'
7373
}
74-
to='/history'
74+
to='/performance'
7575
>
76-
History
76+
Performance
7777
</NavLink>
78+
7879
<NavLink
7980
className={(navData) =>
8081
navData.isActive

src/app/components/StateRoute/WebMetrics/WebMetrics.tsx

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
import React, { useEffect } from 'react';
22
import Charts from 'react-apexcharts';
33
import ReactHover, { Trigger, Hover } from 'react-hover';
4-
import { OptionsCursorTrueWithMargin } from '../../../FrontendTypes';
54
import { setCurrentTabInApp } from '../../../slices/mainSlice';
65
import { useDispatch } from 'react-redux';
7-
/*
8-
Used to render a single radial graph on the 'Web Metrics' tab
9-
*/
106

11-
const radialGraph = (props) => {
7+
const WebMetrics = (props) => {
128
const dispatch = useDispatch();
9+
1310
const state = {
14-
series: [props.series], // series appears to be the scale at which data is displayed based on the type of webMetrics measured.
11+
series: props.series,
1512
options: {
16-
colors: [props.color], // color of the webmetrics performance bar from 'StateRoute'
13+
colors: [props.color],
1714
chart: {
1815
height: 100,
1916
width: 100,
2017
type: 'radialBar',
2118
toolbar: {
2219
show: false,
2320
},
21+
foreColor: 'var(--text-primary)',
2422
},
2523
plotOptions: {
2624
radialBar: {
@@ -48,29 +46,21 @@ const radialGraph = (props) => {
4846
},
4947
},
5048
track: {
51-
background: '#161617',
52-
strokeWidth: '3%',
49+
background: 'var(--border-color-dark)',
50+
strokeWidth: '10%',
5351
margin: 0,
54-
dropShadow: {
55-
enabled: true,
56-
top: -3,
57-
left: 0,
58-
blur: 4,
59-
opacity: 0.35,
60-
},
6152
},
62-
6353
dataLabels: {
6454
show: true,
6555
name: {
6656
offsetY: -10,
6757
show: true,
68-
color: '#161617',
58+
color: 'var(--text-primary)',
6959
fontSize: '24px',
7060
},
7161
value: {
7262
formatter: props.formatted,
73-
color: '#3c6e71',
63+
color: 'var(--color-primary)',
7464
fontSize: '16px',
7565
show: true,
7666
},
@@ -97,12 +87,31 @@ const radialGraph = (props) => {
9787
};
9888

9989
useEffect(() => {
100-
dispatch(setCurrentTabInApp('webmetrics')); // dispatch sent at initial page load allowing changing "immer's" draft.currentTabInApp to 'webmetrics' to facilitate render.
90+
dispatch(setCurrentTabInApp('webmetrics'));
10191
}, []);
10292

93+
const getThresholdColor = (type: string): string => {
94+
switch (type) {
95+
case 'good':
96+
return '#0bce6b';
97+
case 'improvement':
98+
return '#fc5a03';
99+
case 'poor':
100+
return '#fc2000';
101+
default:
102+
return 'var(--text-primary)';
103+
}
104+
};
105+
106+
const hoverOptions = {
107+
followCursor: false,
108+
shiftX: 20,
109+
shiftY: 0,
110+
};
111+
103112
return (
104113
<div className='metric'>
105-
<ReactHover>
114+
<ReactHover options={hoverOptions}>
106115
<Trigger type='trigger'>
107116
<div id='chart' className='chart-container'>
108117
<Charts
@@ -121,15 +130,15 @@ const radialGraph = (props) => {
121130
</p>
122131
<p>{props.description}</p>
123132
<p>
124-
<span style={{ color: '#0bce6b' }}>Good: </span>
133+
<span style={{ color: getThresholdColor('good') }}>Good: </span>
125134
{`< ${props.score[0]}`}
126135
</p>
127136
<p>
128-
<span style={{ color: '#fc5a03' }}>Needs Improvement: </span>
137+
<span style={{ color: getThresholdColor('improvement') }}>Needs Improvement: </span>
129138
{`< ${props.score[1]}`}
130139
</p>
131140
<p>
132-
<span style={{ color: '#fc2000' }}>Poor: </span>
141+
<span style={{ color: getThresholdColor('poor') }}>Poor: </span>
133142
{`> ${props.score[1]}`}
134143
</p>
135144
</div>
@@ -139,4 +148,4 @@ const radialGraph = (props) => {
139148
);
140149
};
141150

142-
export default radialGraph;
151+
export default WebMetrics;

0 commit comments

Comments
 (0)