@@ -26,7 +26,7 @@ type PlotlyData = {
2626} ;
2727
2828const HealthChart : React . FC < HealthChartProps > = React . memo ( props => {
29- const { dataType, chartData, categoryName, sizing, colourGenerator } = props ;
29+ const { dataType, serviceName , chartData, categoryName, sizing, colourGenerator } = props ;
3030 const [ solo , setSolo ] = useState < SoloStyles | null > ( null ) ;
3131
3232 // 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 => {
5151 // generates an array of plotly data objects to be passed into our plotly chart's data prop
5252 const generatePlotlyDataObjects = ( chartDataObj : object ) : object [ ] => {
5353 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 ) ) ;
8062 }
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 ) ;
8176 }
8277 // return the array of plotlyDataObject
8378 return arrayOfPlotlyDataObjects ;
@@ -91,16 +86,16 @@ const HealthChart: React.FC<HealthChartProps> = React.memo(props => {
9186
9287 const createChart = ( ) => {
9388 const dataArray = generatePlotlyDataObjects ( chartData ) ;
94- const serviceNames = serviceNamesAsString ( chartData ) ;
95- console . log ( 'serviceNames : ' , serviceNames ) ;
89+
90+ console . log ( 'serviceName : ' , serviceName ) ;
9691 const sizeSwitch = sizing === 'all' ? all : solo ;
9792
9893 return (
9994 < Plot
10095 data = { dataArray }
10196 config = { { displayModeBar : true } }
10297 layout = { {
103- title : `${ serviceNames } | ${ categoryName } ` ,
98+ title : `${ serviceName } | | ${ categoryName } ` ,
10499 ...sizeSwitch ,
105100 font : {
106101 color : '#444d56' ,
0 commit comments