Skip to content

Commit 5757075

Browse files
DennisLpzkev-ngoCourageWolfC-STYRdemircaner
committed
Fixed Comparison Bargraph X axis Bug and Hovering Bug
Co-authored-by: kev-ngo <[email protected]> Co-authored-by: CourageWolf <[email protected]> Co-authored-by: C-STYR <[email protected]> Co-authored-by: demircaner <[email protected]>
1 parent 1053629 commit 5757075

File tree

3 files changed

+56
-47
lines changed

3 files changed

+56
-47
lines changed

src/app/components/BarGraph.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ const BarGraph = (props) => {
7474
detectBounds: true,
7575
scroll: true,
7676
});
77-
7877
const keys = Object.keys(data.componentData);
7978

8079
// data accessor (used to generate scales) and formatter (add units for on hover box)
@@ -122,7 +121,7 @@ const BarGraph = (props) => {
122121
yScale={renderingScale}
123122
width={xMax}
124123
height={yMax}
125-
stroke="black"
124+
stroke='black'
126125
strokeOpacity={0.1}
127126
xOffset={snapshotIdScale.bandwidth() / 2}
128127
/>
@@ -208,16 +207,16 @@ const BarGraph = (props) => {
208207
/>
209208
<Text
210209
x={-xMax / 2}
211-
y="15"
212-
transform="rotate(-90)"
210+
y='15'
211+
transform='rotate(-90)'
213212
fontSize={12}
214-
fill="#FFFFFF"
213+
fill='#FFFFFF'
215214
>
216-
Rendering Time (ms)
215+
Rendering Time (ms)
217216
</Text>
218-
<br/>
219-
<Text x={(xMax / 2) + 15} y={yMax + 70} fontSize={12} fill="#FFFFFF">
220-
Snapshot ID
217+
<br />
218+
<Text x={xMax / 2 + 15} y={yMax + 70} fontSize={12} fill='#FFFFFF'>
219+
Snapshot ID
221220
</Text>
222221
</svg>
223222
{/* FOR HOVER OVER DISPLAY */}

src/app/components/BarGraphComparison.tsx

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ const BarGraphComparison = (props) => {
102102
const getSnapshotId = (d: snapshot) => d.snapshotId;
103103
const formatSnapshotId = (id) => `Snapshot ID: ${id}`;
104104
const formatRenderTime = (time) => `${time} ms `;
105-
105+
const getTabID = (storedSeries) => storedSeries.currentTab;
106106
// create visualization SCALES with cleaned data
107+
//const xAxisPoints = [...titleFilter(comparison).map(getTabID), currentTab];
107108
//the domain array elements will place the bars along the x-axis
109+
const xAxisPoints = ['currentTab', 'comparison']; //[1.0.,2.0]
110+
//{ currentTab : 1 }, {currentTab : 2 }
108111
const snapshotIdScale = scaleBand<string>({
109-
domain: [
110-
`Current Tab Series`,
111-
`Series ${!comparison[series] ? null : series + 1}`,
112-
],
112+
domain: xAxisPoints,
113113
padding: 0.2,
114114
});
115115
// calculateMax
@@ -165,14 +165,17 @@ const BarGraphComparison = (props) => {
165165

166166
const handleChange = (event) => {
167167
setSeries(event.target.value);
168+
setXpoints();
168169
};
169170

170171
const handleClose = () => {
171172
setOpen(false);
173+
setXpoints();
172174
};
173175

174176
const handleOpen = () => {
175177
setOpen(true);
178+
setXpoints();
176179
};
177180

178181
const toStorage = {
@@ -181,20 +184,29 @@ const BarGraphComparison = (props) => {
181184
data,
182185
};
183186

187+
//manually assignin X -axis points with tab ID.
188+
function setXpoints() {
189+
comparison[series].data.barStack.forEach((elem) => {
190+
elem.currentTab = 'comparison';
191+
});
192+
//comparison[series].data.barStack.currentTab = currentTab;
193+
return comparison[series].data.barStack;
194+
}
195+
184196
return (
185197
<div>
186-
<div className="series-options-container">
187-
<div className="snapshotId-header">
198+
<div className='series-options-container'>
199+
<div className='snapshotId-header'>
188200
{' '}
189201
Snapshot ID: {currentIndex + 1}{' '}
190202
</div>
191203

192-
<div className="dropdown-and-save-series-container">
193-
<FormControl variant="outlined" className={classes.formControl}>
204+
<div className='dropdown-and-save-series-container'>
205+
<FormControl variant='outlined' className={classes.formControl}>
194206
<Select
195207
style={{ color: 'white' }}
196-
labelId="simple-select-outlined-label"
197-
id="simple-select-outlined"
208+
labelId='simple-select-outlined-label'
209+
id='simple-select-outlined'
198210
className={classes.select}
199211
open={open}
200212
onClose={handleClose}
@@ -215,7 +227,7 @@ const BarGraphComparison = (props) => {
215227
</FormControl>
216228

217229
<button
218-
className="save-series-button"
230+
className='save-series-button'
219231
onClick={() => dispatch(save(toStorage))}
220232
>
221233
Save Series
@@ -240,7 +252,7 @@ const BarGraphComparison = (props) => {
240252
yScale={renderingScale}
241253
width={xMax}
242254
height={yMax}
243-
stroke="black"
255+
stroke='black'
244256
strokeOpacity={0.1}
245257
xOffset={snapshotIdScale.bandwidth() / 2}
246258
/>
@@ -257,11 +269,10 @@ const BarGraphComparison = (props) => {
257269
{(barStacks) =>
258270
barStacks.map((barStack, idx) => {
259271
const bar = barStack.bars[currentIndex];
260-
261272
return (
262273
<rect
263274
key={`bar-stack-${idx}-NewView`}
264-
x={bar.x + 30}
275+
x={bar.x}
265276
y={bar.y}
266277
height={bar.height === 0 ? null : bar.height}
267278
width={bar.width}
@@ -295,9 +306,9 @@ const BarGraphComparison = (props) => {
295306
</BarStack>
296307
<BarStack
297308
// Comparison Barstack
298-
data={!comparison[series] ? [] : comparison[series].data.barStack}
309+
data={!comparison[series] ? [] : setXpoints()}
299310
keys={keys}
300-
x={getSnapshotId}
311+
x={getTabID}
301312
xScale={snapshotIdScale}
302313
yScale={renderingScale}
303314
color={colorScale}
@@ -308,11 +319,10 @@ const BarGraphComparison = (props) => {
308319
return <h1>No Comparison</h1>;
309320
}
310321
const bar = barStack.bars[currentIndex];
311-
312322
return (
313323
<rect
314324
key={`bar-stack-${idx}-${bar.index}`}
315-
x={225}
325+
x={bar.x}
316326
y={bar.y}
317327
height={bar.height === 0 ? null : bar.height}
318328
width={bar.width}
@@ -374,14 +384,14 @@ const BarGraphComparison = (props) => {
374384
/>
375385
<Text
376386
x={-xMax / 2}
377-
y="15"
378-
transform="rotate(-90)"
387+
y='15'
388+
transform='rotate(-90)'
379389
fontSize={12}
380-
fill="#FFFFFF"
390+
fill='#FFFFFF'
381391
>
382392
Rendering Time (ms)
383393
</Text>
384-
<Text x={xMax / 2} y={yMax + 65} fontSize={12} fill="#FFFFFF">
394+
<Text x={xMax / 2} y={yMax + 65} fontSize={12} fill='#FFFFFF'>
385395
Series ID
386396
</Text>
387397
</svg>

src/app/components/PerformanceVisx.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const allStorage = () => {
8989
return values;
9090
};
9191

92-
// Get snapshot Ids for the regular bar graph view.
92+
// Gets snapshot Ids for the regular bar graph view.
9393
const getSnapshotIds = (obj, snapshotIds = []): string[] => {
9494
snapshotIds.push(`${obj.name}.${obj.branch}`);
9595
if (obj.children) {
@@ -149,43 +149,43 @@ const PerformanceVisx = (props: BarStackProps) => {
149149
if (hierarchy) {
150150
return <RenderingFrequency data={data.componentData} />;
151151
}
152-
return <div className="noState">{NO_STATE_MSG}</div>;
152+
return <div className='noState'>{NO_STATE_MSG}</div>;
153153
};
154154

155155
return (
156156
<Router>
157-
<div className="performance-nav-bar-container">
157+
<div className='performance-nav-bar-container'>
158158
<NavLink
159-
className="router-link-performance"
159+
className='router-link-performance'
160160
// className="router-link"
161-
activeClassName="is-active"
161+
activeClassName='is-active'
162162
exact
163-
to="/"
163+
to='/'
164164
>
165165
Snapshots View
166166
</NavLink>
167167
<NavLink
168-
className="router-link-performance"
168+
className='router-link-performance'
169169
// className="router-link"
170-
activeClassName="is-active"
171-
to="/comparison"
170+
activeClassName='is-active'
171+
to='/comparison'
172172
>
173173
Comparison View
174174
</NavLink>
175175
<NavLink
176-
className="router-link-performance"
176+
className='router-link-performance'
177177
// className="router-link"
178-
activeClassName="is-active"
179-
to="/componentdetails"
178+
activeClassName='is-active'
179+
to='/componentdetails'
180180
>
181181
Component Details
182182
</NavLink>
183183
</div>
184184

185185
<Switch>
186-
<Route path="/comparison" render={renderComparisonBargraph} />
187-
<Route path="/componentdetails" render={renderComponentDetailsView} />
188-
<Route path="/" render={renderBargraph} />
186+
<Route path='/comparison' render={renderComparisonBargraph} />
187+
<Route path='/componentdetails' render={renderComponentDetailsView} />
188+
<Route path='/' render={renderBargraph} />
189189
</Switch>
190190
</Router>
191191
);

0 commit comments

Comments
 (0)