Skip to content

Commit b1ef068

Browse files
committed
Merge branch 'staging' of https://github.com/oslabs-beta/reactime into commas
2 parents 0b9efe6 + b2e1af4 commit b1ef068

File tree

9 files changed

+616
-378
lines changed

9 files changed

+616
-378
lines changed

src/app/components/BarGraph.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ const BarGraph = (props) => {
142142
if (Number.isNaN(bar.bar[1]) || bar.height < 0) {
143143
bar.height = 0;
144144
}
145-
console.log('bar in BarGraph.tsx', bar);
146145
return (
147146
<rect
148147
key={`bar-stack-${barStack.id}-${bar.id}`}

src/app/components/BarGraphComparison.tsx

Lines changed: 30 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import FormHelperText from '@material-ui/core/FormHelperText';
1919
import snapshots from './snapshots';
2020
import { onHover, onHoverExit } from '../actions/actions';
2121
import { useStoreContext } from '../store';
22+
import { save } from '../actions/actions';
2223
/* TYPESCRIPT */
2324
interface data {
2425
snapshotId?: string;
@@ -71,31 +72,18 @@ const tooltipStyles = {
7172
const BarGraphComparison = (props) => {
7273
const [{ tabs, currentTab }, dispatch] = useStoreContext();
7374
const { width, height, data, comparison } = props;
74-
7575
const [series, setSeries] = React.useState(0);
7676
const [open, setOpen] = React.useState(false);
7777
const [maxRender, setMaxRender] = React.useState(data.maxTotalRender);
7878

79-
// console.log('comparison >>>', comparison);
80-
// console.log('tabs[currentTab] >>>', tabs[currentTab]);
81-
// console.log('props in comparison graph >>>', props);
82-
// console.log('data >>>>>', data);
83-
// change scale of graph based on clicking of forward and backwards buttons effect
84-
// useEffect(() => {
85-
// console.log('setSeries is changing everytime currentIndex changes');
86-
// //change the state with setChangeSeries
87-
// setSeries(tabs[currentTab].sliderIndex);
88-
// }, [tabs[currentTab].sliderIndex]);
89-
90-
// console.log('tabs in Bargraphs comparison >>', tabs);
9179
function titleFilter(comparisonArray) {
9280
return comparisonArray.filter(
9381
(elem) => elem.title === tabs[currentTab].title
9482
);
9583
}
96-
// console.log('tabs in BGComp >>>', tabs);
84+
9785
const currentIndex = tabs[currentTab].sliderIndex;
98-
// console.log('sliderIndx outside of bargraph >>>', currentIndex);
86+
9987
const {
10088
tooltipOpen,
10189
tooltipLeft,
@@ -116,16 +104,15 @@ const BarGraphComparison = (props) => {
116104
const formatRenderTime = (time) => `${time} ms `;
117105

118106
// create visualization SCALES with cleaned data
107+
//the domain array elements will place the bars along the x-axis
119108
const snapshotIdScale = scaleBand<string>({
120-
// domain: getSnapshotId(data.barStack[currentIndex]),
121-
// domain: [currentTab, comparison[series].currentTab],
122109
domain: [
123110
`Current Tab Series`,
124111
`Series ${!comparison[series] ? null : series + 1}`,
125112
],
126113
padding: 0.2,
127114
});
128-
115+
// calculateMax
129116
const calculateMaxTotalRender = (series) => {
130117
const currentSeriesBarStacks = !comparison[series]
131118
? []
@@ -150,28 +137,23 @@ const BarGraphComparison = (props) => {
150137
range: schemeSet3,
151138
});
152139

153-
// console.log('rendering scale invocation', renderingScale);
154140
// setting max dimensions and scale ranges
155141
const xMax = width - margin.left - margin.right;
156-
const yMax = height - margin.top - 150;
142+
const yMax = height - margin.top - 200;
157143
snapshotIdScale.rangeRound([0, xMax]);
158144
renderingScale.range([yMax, 0]);
159145

160-
// const filterSeries = (comparisonArray) => {
161-
// return comparisonArray.map((sessionName, idx) => {
162-
// return <MenuItem>{sessionName}</MenuItem>;
163-
// });
164-
// };
165146
// Dropdown to select series.
166147
const useStyles = makeStyles((theme) => ({
167148
formControl: {
168149
margin: theme.spacing(1),
169150
minWidth: 80,
170-
// padding: '0.5rem',
171151
height: 30,
172152
},
173153
select: {
174154
minWidth: 80,
155+
fontSize: '.75rem',
156+
fontWeight: '200',
175157
border: '1px solid grey',
176158
borderRadius: 4,
177159
color: 'grey',
@@ -183,9 +165,6 @@ const BarGraphComparison = (props) => {
183165

184166
const handleChange = (event) => {
185167
setSeries(event.target.value);
186-
// console.log('handleCh renderTime', renderTime);
187-
// // setMaxRender(renderTime);
188-
// console.log('maxRender', maxRender);
189168
};
190169

191170
const handleClose = () => {
@@ -196,34 +175,20 @@ const BarGraphComparison = (props) => {
196175
setOpen(true);
197176
};
198177

199-
//this function creates a dropdown selection for each series of snapshots saved
200-
// const filterSeries = (comparisonArray) => {
201-
// return comparisonArray.map((sessionName, idx) => {
202-
// return <MenuItem>{sessionName}</MenuItem>;
203-
// });
204-
// };
178+
const toStorage = {
179+
currentTab,
180+
title: tabs[currentTab]['title'],
181+
data,
182+
};
205183

206184
return (
207185
<div>
208-
{/* <h1>{`Current Snapshot: ${currentIndex + 1}`}</h1> */}
209-
{/* <div class="dropdown dropdown-dark">
210-
<select name="two" class="dropdown-select">
211-
{!comparison[series] ? (
212-
<option value={series}>No series available</option>
213-
) : (
214-
titleFilter(comparison).map((tabElem, index) => {
215-
return <option value={index}>{`Series ${index + 1}`}</option>;
216-
})
217-
)}
218-
</select>
219-
</div> */}
220186
<div className="series-options-container">
221-
<div className="snapshotId-container">
222-
<h1 className="snashotId-header">
223-
{' '}
224-
Snapshot ID: {currentIndex + 1}{' '}
225-
</h1>
187+
<div className="snapshotId-header">
188+
{' '}
189+
Snapshot ID: {currentIndex + 1}{' '}
226190
</div>
191+
227192
<div className="dropdown-and-save-series-container">
228193
<FormControl variant="outlined" className={classes.formControl}>
229194
<Select
@@ -235,8 +200,6 @@ const BarGraphComparison = (props) => {
235200
onClose={handleClose}
236201
onOpen={handleOpen}
237202
value={series}
238-
//data={data.barStack}
239-
// value={titleFilter(comparison)}
240203
onChange={handleChange}
241204
>
242205
{!comparison[series] ? (
@@ -250,8 +213,16 @@ const BarGraphComparison = (props) => {
250213
)}
251214
</Select>
252215
</FormControl>
216+
217+
<button
218+
className="save-series-button"
219+
onClick={() => dispatch(save(toStorage))}
220+
>
221+
Save Series
222+
</button>
253223
</div>
254224
</div>
225+
255226
<svg ref={containerRef} width={width} height={height}>
256227
{}
257228
<rect
@@ -276,27 +247,21 @@ const BarGraphComparison = (props) => {
276247
<Group top={margin.top} left={margin.left}>
277248
<BarStack
278249
// OG Barstack
279-
// data={!comparison ? [] : comparison}
280250
data={data.barStack}
281251
keys={keys}
282-
// x={getSnapshotId}
283252
x={getSnapshotId}
284253
xScale={snapshotIdScale}
285254
yScale={renderingScale}
286255
color={colorScale}
287256
>
288257
{(barStacks) =>
289258
barStacks.map((barStack, idx) => {
290-
console.log('maxTotalRender 1st Barstack', data.maxTotalRender);
291259
const bar = barStack.bars[currentIndex];
292-
// console.log('Y SCALEEE', barStacks);
293-
// console.log('data.barStack >>>', data.barStack);
294-
console.log('OG bar.x', bar.x);
295260

296261
return (
297262
<rect
298263
key={`bar-stack-${idx}-NewView`}
299-
x={bar.x + 50}
264+
x={bar.x + 30}
300265
y={bar.y}
301266
height={bar.height === 0 ? null : bar.height}
302267
width={bar.width}
@@ -331,10 +296,8 @@ const BarGraphComparison = (props) => {
331296
<BarStack
332297
// Comparison Barstack
333298
data={!comparison[series] ? [] : comparison[series].data.barStack}
334-
// data={data.barStack}
335299
keys={keys}
336300
x={getSnapshotId}
337-
// x={getSeriesId}
338301
xScale={snapshotIdScale}
339302
yScale={renderingScale}
340303
color={colorScale}
@@ -344,13 +307,12 @@ const BarGraphComparison = (props) => {
344307
if (!barStack.bars[currentIndex]) {
345308
return <h1>No Comparison</h1>;
346309
}
347-
// console.log('barStacks in Comparison', barStacks);
348310
const bar = barStack.bars[currentIndex];
349-
console.log('Comparison bar.x', bar.x);
311+
350312
return (
351313
<rect
352314
key={`bar-stack-${idx}-${bar.index}`}
353-
x={275}
315+
x={225}
354316
y={bar.y}
355317
height={bar.height === 0 ? null : bar.height}
356318
width={bar.width}
@@ -417,12 +379,10 @@ const BarGraphComparison = (props) => {
417379
fontSize={12}
418380
fill="#FFFFFF"
419381
>
420-
{' '}
421-
Rendering Time (ms){' '}
382+
Rendering Time (ms)
422383
</Text>
423384
<Text x={xMax / 2} y={yMax + 65} fontSize={12} fill="#FFFFFF">
424-
{' '}
425-
Series ID{' '}
385+
Series ID
426386
</Text>
427387
</svg>
428388
{/* FOR HOVER OVER DISPLAY */}

src/app/components/ComponentMap.tsx

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ import { onHover, onHoverExit } from '../actions/actions';
1818
import { useStoreContext } from '../store';
1919

2020
const root = hierarchy({
21-
name: 'root',
21+
name: "root",
2222
children: [
23-
{ name: 'child #1' },
23+
{ name: "child #1" },
2424
{
25-
name: 'child #2',
25+
name: "child #2",
2626
children: [
27-
{ name: 'grandchild #1' },
28-
{ name: 'grandchild #2' },
29-
{ name: 'grandchild #3' },
27+
{ name: "grandchild #1" },
28+
{ name: "grandchild #2" },
29+
{ name: "grandchild #3" },
3030
],
3131
},
3232
],
@@ -61,9 +61,9 @@ export default function ComponentMap({
6161
const data: {} = snapshots[lastNode];
6262

6363
// importing custom hooks for the selection tabs.
64-
const [layout, setLayout] = useState('cartesian');
65-
const [orientation, setOrientation] = useState('horizontal');
66-
const [linkType, setLinkType] = useState('diagonal');
64+
const [layout, setLayout] = useState("cartesian");
65+
const [orientation, setOrientation] = useState("horizontal");
66+
const [linkType, setLinkType] = useState("diagonal");
6767
const [stepPercent, setStepPercent] = useState(10);
6868

6969
// Declared this variable and assigned it to the useForceUpdate function that forces a state to change causing that component to re-render and display on the map
@@ -79,7 +79,7 @@ export default function ComponentMap({
7979

8080
// This sets the starting position for the root node on the maps display. the polar layout sets the root node to the relative center of the display box based on the size of the browser window.
8181
// the else conditional statements determines the root nodes location either in the left middle or top middle of the browser window relative to the size of the browser.
82-
if (layout === 'polar') {
82+
if (layout === "polar") {
8383
origin = {
8484
x: innerWidth / 2,
8585
y: innerHeight / 2,
@@ -88,7 +88,7 @@ export default function ComponentMap({
8888
sizeHeight = Math.min(innerWidth, innerHeight) / 2;
8989
} else {
9090
origin = { x: 0, y: 0 };
91-
if (orientation === 'vertical') {
91+
if (orientation === "vertical") {
9292
sizeWidth = innerWidth;
9393
sizeHeight = innerHeight;
9494
} else {
@@ -176,11 +176,11 @@ export default function ComponentMap({
176176

177177
let top: number;
178178
let left: number;
179-
if (layout === 'polar') {
179+
if (layout === "polar") {
180180
const [radialX, radialY] = pointRadial(node.x, node.y);
181181
top = radialY;
182182
left = radialX;
183-
} else if (orientation === 'vertical') {
183+
} else if (orientation === "vertical") {
184184
top = node.y;
185185
left = node.x;
186186
} else {
@@ -198,7 +198,6 @@ export default function ComponentMap({
198198
const tooltipObj = Object.assign({}, node.data);
199199
if (typeof tooltipObj.state === 'object')
200200
tooltipObj.state = 'stateful';
201-
console.log('tooltipObj', tooltipObj);
202201
showTooltip({
203202
tooltipLeft: coords.x,
204203
tooltipTop: coords.y,
@@ -226,10 +225,10 @@ export default function ComponentMap({
226225
width={width}
227226
y={-height / 2}
228227
x={-width / 2}
229-
fill={node.children ? '#161521' : '#62d6fb'}
230-
stroke={node.children ? '#62d6fb' : '#161521'}
228+
fill={node.children ? "#161521" : "#62d6fb"}
229+
stroke={node.children ? "#62d6fb" : "#161521"}
231230
strokeWidth={1}
232-
strokeDasharray={node.children ? '0' : '2,2'}
231+
strokeDasharray={node.children ? "0" : "2,2"}
233232
strokeOpacity="1"
234233
rx={node.children ? 4 : 10}
235234
onClick={() => {
@@ -240,6 +239,8 @@ export default function ComponentMap({
240239
//test feature
241240
onMouseOver={handleMouseOver}
242241
onMouseOut={hideTooltip}
242+
onMouseEnter={() => dispatch(onHover(node.data.rtid))}
243+
onMouseLeave={() => dispatch(onHoverExit(node.data.rtid))}
243244
/>
244245
)}
245246
{/* Display text inside of each component node */}
@@ -248,13 +249,13 @@ export default function ComponentMap({
248249
fontSize={10}
249250
fontFamily="Roboto"
250251
textAnchor="middle"
251-
style={{ pointerEvents: 'none' }}
252+
style={{ pointerEvents: "none" }}
252253
fill={
253254
node.depth === 0
254-
? '#161521'
255+
? "#161521"
255256
: node.children
256-
? 'white'
257-
: '#161521'
257+
? "white"
258+
: "#161521"
258259
}
259260
>
260261
{node.data.name}

0 commit comments

Comments
 (0)