@@ -5,22 +5,20 @@ import CommunicationsContext from '../context/OverviewContext';
55const ResponseCodeChart = ( props ) => {
66 const communicationsData = useContext ( CommunicationsContext ) . overviewData ;
77
8-
9-
108 const createChart = ( ) => {
119 const responseCodes = {
1210 '100-199' : 0 ,
1311 '200-299' : 0 ,
1412 '300-399' : 0 ,
1513 '400-499' : 0 ,
1614 '500-599' : 0 ,
17- ' NULL' : 0 ,
15+ NULL : 0 ,
1816 } ;
1917
2018 for ( let i = 0 ; i < communicationsData . length ; i += 1 ) {
2119 const element = communicationsData [ i ] ;
2220 // If Mongo Else SQL
23- if ( ( element . currentMicroservice === props . service ) && element . resStatus ) {
21+ if ( element . currentMicroservice === props . service && element . resStatus ) {
2422 const statusCode = element . resStatus ;
2523 if ( statusCode <= 199 ) {
2624 responseCodes [ '100-199' ] += 1 ;
@@ -33,9 +31,12 @@ const ResponseCodeChart = (props) => {
3331 } else if ( statusCode <= 599 ) {
3432 responseCodes [ '500-599' ] += 1 ;
3533 } else {
36- responseCodes [ ' NULL' ] += 1 ;
34+ responseCodes . NULL += 1 ;
3735 }
38- } else if ( ( element . currentmicroservice === props . service ) && element . resstatus ) {
36+ } else if (
37+ element . currentmicroservice === props . service &&
38+ element . resstatus
39+ ) {
3940 const statusCode = element . resstatus ;
4041 if ( statusCode <= 199 ) {
4142 responseCodes [ '100-199' ] += 1 ;
@@ -48,44 +49,57 @@ const ResponseCodeChart = (props) => {
4849 } else if ( statusCode <= 599 ) {
4950 responseCodes [ '500-599' ] += 1 ;
5051 } else {
51- responseCodes [ ' NULL' ] += 1 ;
52+ responseCodes . NULL += 1 ;
5253 }
5354 }
5455 }
5556
5657 return (
5758 < Plot
58- data = { [ {
59- values : Object . values ( responseCodes ) ,
60- labels : [ 'Informational 1xx' , 'Successful 2xx' , 'Redirection 3xx' , 'Client Error 4xx' , 'Server Error 5xx' ] ,
61- type : 'pie' ,
62- domain : { y : [ 0 , 2 ] } ,
63- marker : {
64- 'colors' : [
65- '#f38181' ,
66- '#fce38a' ,
67- '#fcbad3' ,
68- '#95e1d3' ,
69- '#a8d8ea' ,
70- '#aa96da' ,
71- ]
72- }
73- } ] }
74- layout = { {
75- height : 400 ,
76- width : 400 ,
77- displaylogo : false ,
78- paper_bgcolor : '#fffbe0' ,
79- legend : {
80- orientation : 'h' ,
81- xanchor : 'center' ,
82- x : .5 ,
83- y : 5
84- }
85- } }
86- /> )
59+ data = { [
60+ {
61+ values : Object . values ( responseCodes ) ,
62+ labels : [
63+ 'Informational 1xx' ,
64+ 'Successful 2xx' ,
65+ 'Redirection 3xx' ,
66+ 'Client Error 4xx' ,
67+ 'Server Error 5xx' ,
68+ ] ,
69+ type : 'pie' ,
70+ domain : { y : [ 0 , 2 ] } ,
71+ marker : {
72+ colors : [
73+ '#4897d8' ,
74+ '#ffdb5c' ,
75+ '#fa6e59' ,
76+ '#f8a055' ,
77+ '#73605b' ,
78+ '#d09683' ,
79+ ] ,
80+ } ,
81+ } ,
82+ ] }
83+ layout = { {
84+ height : 400 ,
85+ width : 400 ,
86+ font : {
87+ color : 'azure' ,
88+ size : 15
89+ } ,
90+ displaylogo : false ,
91+ paper_bgcolor : '#8BA6B9' ,
92+ legend : {
93+ orientation : 'h' ,
94+ xanchor : 'center' ,
95+ x : 0.5 ,
96+ y : 5 ,
97+ } ,
98+ } }
99+ />
100+ ) ;
87101 } ;
88-
102+
89103 return < div > { createChart ( ) } </ div > ;
90104} ;
91105
0 commit comments