@@ -26,7 +26,7 @@ type PlotlyData = {
26
26
} ;
27
27
28
28
const HealthChart : React . FC < HealthChartProps > = React . memo ( props => {
29
- const { dataType, chartData, categoryName, sizing, colourGenerator } = props ;
29
+ const { dataType, serviceName , chartData, categoryName, sizing, colourGenerator } = props ;
30
30
const [ solo , setSolo ] = useState < SoloStyles | null > ( null ) ;
31
31
32
32
// makes time data human-readable, and reverses it so it shows up correctly in the graph
@@ -51,33 +51,28 @@ const HealthChart: React.FC<HealthChartProps> = React.memo(props => {
51
51
// generates an array of plotly data objects to be passed into our plotly chart's data prop
52
52
const generatePlotlyDataObjects = ( chartDataObj : object ) : object [ ] => {
53
53
const arrayOfPlotlyDataObjects : PlotlyData [ ] = [ ] ;
54
- // iterate through the chartData
55
- for ( const serviceName in chartDataObj ) {
56
- // define the metrics for this service
57
- const metrics = chartDataObj [ serviceName ] ;
58
- // loop through the list of metrics for the current service
59
- for ( const metricName in metrics ) {
60
- // define the value and time arrays; allow data to be reassignable in case we need to convert the bytes data into megabytes
61
- let dataArray = metrics [ metricName ] . value ;
62
- const timeArray = metrics [ metricName ] . time ;
63
- // specifically for `Megabyte` types, convert the original data of bytes into a value of megabytes before graphing
64
- if ( dataType === 'Memory in Megabytes' || dataType === 'Cache in Megabytes' ) {
65
- dataArray = dataArray . map ( value => ( value / 1000000 ) . toFixed ( 2 ) ) ;
66
- }
67
- // create the plotly object
68
- const plotlyDataObject : PlotlyData = {
69
- name : prettyMetricName ( metricName ) ,
70
- x : prettyTimeInReverse ( timeArray ) ,
71
- y : dataArray ,
72
- type : 'scattergl' ,
73
- mode : 'lines' ,
74
- marker : {
75
- colors : [ '#fc4039' , '#4b54ea' , '#32b44f' , '#3788fc' , '#9c27b0' , '#febc2c' ] ,
76
- } ,
77
- } ;
78
- // push the dataObject into the arrayOfPlotlyDataObjects
79
- arrayOfPlotlyDataObjects . push ( plotlyDataObject ) ;
54
+ // loop through the list of metrics for the current chart
55
+ for ( const metricName in chartDataObj ) {
56
+ // define the value and time arrays; allow data to be reassignable in case we need to convert the bytes data into megabytes
57
+ let dataArray = chartDataObj [ metricName ] . value ;
58
+ const timeArray = chartDataObj [ metricName ] . time ;
59
+ // specifically for `Megabyte` types, convert the original data of bytes into a value of megabytes before graphing
60
+ if ( dataType === 'Memory in Megabytes' || dataType === 'Cache in Megabytes' ) {
61
+ dataArray = dataArray . map ( value => ( value / 1000000 ) . toFixed ( 2 ) ) ;
80
62
}
63
+ // create the plotly object
64
+ const plotlyDataObject : PlotlyData = {
65
+ name : prettyMetricName ( metricName ) ,
66
+ x : prettyTimeInReverse ( timeArray ) ,
67
+ y : dataArray ,
68
+ type : 'scattergl' ,
69
+ mode : 'lines' ,
70
+ marker : {
71
+ colors : [ '#fc4039' , '#4b54ea' , '#32b44f' , '#3788fc' , '#9c27b0' , '#febc2c' ] ,
72
+ } ,
73
+ } ;
74
+ // push the dataObject into the arrayOfPlotlyDataObjects
75
+ arrayOfPlotlyDataObjects . push ( plotlyDataObject ) ;
81
76
}
82
77
// return the array of plotlyDataObject
83
78
return arrayOfPlotlyDataObjects ;
@@ -91,16 +86,16 @@ const HealthChart: React.FC<HealthChartProps> = React.memo(props => {
91
86
92
87
const createChart = ( ) => {
93
88
const dataArray = generatePlotlyDataObjects ( chartData ) ;
94
- const serviceNames = serviceNamesAsString ( chartData ) ;
95
- console . log ( 'serviceNames : ' , serviceNames ) ;
89
+
90
+ console . log ( 'serviceName : ' , serviceName ) ;
96
91
const sizeSwitch = sizing === 'all' ? all : solo ;
97
92
98
93
return (
99
94
< Plot
100
95
data = { dataArray }
101
96
config = { { displayModeBar : true } }
102
97
layout = { {
103
- title : `${ serviceNames } | ${ categoryName } ` ,
98
+ title : `${ serviceName } | | ${ categoryName } ` ,
104
99
...sizeSwitch ,
105
100
font : {
106
101
color : '#444d56' ,
0 commit comments