Skip to content

Commit 3b2c10c

Browse files
authored
Merge pull request #30 from Chronos2-0/fixedChartTraffic
fixed traffic visualization of pinged servers properly
2 parents ea97d07 + 8c4f5b5 commit 3b2c10c

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

app/charts/microservice-traffic.jsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const MicroServiceTraffic = (props) => {
2929
}
3030

3131
else {
32-
3332
for (let i = communicationsData.length-1; i >= 0; i--) {
3433
const element = communicationsData[i];
3534
if (resObj[element.correlatingid]) resObj[element.correlatingid].push(element.currentmicroservice);
@@ -40,26 +39,30 @@ const MicroServiceTraffic = (props) => {
4039

4140
//use object values to destructure locations
4241
const tracePoints = Object.values(resObj);
43-
let position = communicationsData[0].correlatingid ? 0 : tracePoints.length-1;
44-
42+
4543
// Declare Micro-server-count dictinary to capture the amount of times a particular server is hit
4644
const microServiceCountdictionary = {};
4745

46+
//array logging every ping present in communications table ---> flat used to flatten multidimensional array and return 1d array
47+
const tracePointLog = tracePoints.flat(Infinity);
48+
4849
// iterate over Trace Points
49-
for (let i = 0; i < tracePoints[position].length; i+=1) {
50+
for (let i = 0; i < tracePointLog.length; i+=1) {
5051

5152
// populate Micro-count dictionary
52-
if (!microServiceCountdictionary[tracePoints[position][i]]) {
53-
microServiceCountdictionary[tracePoints[position][i]] = 1;
53+
if (!microServiceCountdictionary[tracePointLog[i]]) {
54+
microServiceCountdictionary[tracePointLog[i]] = 1;
5455
} else {
55-
microServiceCountdictionary[tracePoints[position][i]]+=1
56+
microServiceCountdictionary[tracePointLog[i]]+=1
5657
}
5758
};
5859

5960
// capture values of microServiceCountdictionary to use as data to populate chart object
6061
const serverPingCount = Object.values(microServiceCountdictionary);
6162

62-
63+
// variable 10 points higher than max number in microservicesDictionary aggregation --> variable allows for top level spacing on bar graph
64+
const yAxisHeadRoom = (Math.max(...serverPingCount) + 10);
65+
6366
// Create chart object data to feed into bar component
6467
const myChart = {
6568
//spread dictionary keys inorder to properly label chart x axis
@@ -70,9 +73,9 @@ const MicroServiceTraffic = (props) => {
7073
backgroundColor: 'rgba(241, 207, 70,1)',
7174
borderColor: 'rgba(0,0,0,1)',
7275
borderWidth: 1,
73-
data: [...serverPingCount, 0] // spread ping count array into data array to have chart populate the Y axis
76+
data: [...serverPingCount, 0, yAxisHeadRoom] // spread ping count array into data array to have chart populate the Y axis
7477
}
75-
]
78+
],
7679
}
7780

7881

app/components/Modal.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ const Modal = (props) => {
2929

3030
// event.stopPropogation allows the user to interact with the chart as opposed to a click on the
3131
// chart bubbling out and closing the Modal.
32-
33-
console.log('Modal Props: ', props);
34-
console.log('Modal props.modalChart: ', modalChart);
32+
3533
return (
3634
<div id="modalWindow" onClick={() => toggleModalDisplay(!toggleModalDisplay)}>
3735
<div id="modalContent" onClick={(event) => event.stopPropagation()}>

0 commit comments

Comments
 (0)