33 useMetricsTimeSpan ,
44 useChartId ,
55} from '@scality/core-ui/dist/next' ;
6- import { useChartLegend } from '@scality/core-ui/dist/components/chartlegend/ChartLegendWrapper ' ;
6+ import { useChartLegendRegistration } from '../hooks/useChartLegendRegistration ' ;
77
8- import { useCallback , useEffect } from 'react' ;
8+ import { useCallback } from 'react' ;
99import {
1010 useNodeAddressesSelector ,
1111 useNodes ,
@@ -22,7 +22,11 @@ import {
2222} from '../services/platformlibrary/metrics' ;
2323import { getMultipleSymmetricalSeries } from '../services/graphUtils' ;
2424import SymmetricalQuantileChart from './SymmetricalQuantileChart' ;
25- import { UNIT_RANGE_BS , YAXIS_TITLE_READ_WRITE } from '../constants' ;
25+ import {
26+ HEIGHT_SYMMETRICAL_CHART ,
27+ UNIT_RANGE_BS ,
28+ YAXIS_TITLE_READ_WRITE ,
29+ } from '../constants' ;
2630
2731const DashboardChartThroughput = ( ) => {
2832 const { isShowQuantileChart } = useShowQuantileChart ( ) ;
@@ -52,18 +56,15 @@ const DashboardChartThroughput = () => {
5256
5357const DashboardChartThroughputWithoutQuantile = ( ) => {
5458 const chartId = useChartId ( ) ;
55- const { register } = useChartLegend ( ) ;
5659 const nodes = useNodes ( ) ;
5760 const nodeAddresses = useNodeAddressesSelector ( nodes ) ;
5861
5962 const { interval, duration } = useMetricsTimeSpan ( ) ;
6063 const { isLoading, series, startingTimeStamp } = useSymetricalChartSeries ( {
6164 getAboveQueries : ( timeSpanProps ) => [
62- // @ts -expect-error - FIXME when you are working on it
6365 getNodesThroughputWriteQuery ( timeSpanProps ) ,
6466 ] ,
6567 getBelowQueries : ( timeSpanProps ) => [
66- // @ts -expect-error - FIXME when you are working on it
6768 getNodesThroughputReadQuery ( timeSpanProps ) ,
6869 ] ,
6970 transformPrometheusDataToSeries : useCallback (
@@ -83,41 +84,23 @@ const DashboardChartThroughputWithoutQuantile = () => {
8384 nodeAddresses ,
8485 ) ;
8586
86- const aboveSeries = allSeries . filter (
87- ( serie ) => serie . metricPrefix === 'write' ,
88- ) ;
89-
90- const belowSeries = allSeries . filter (
91- ( serie ) => serie . metricPrefix === 'read' ,
92- ) ;
93- return {
94- above : aboveSeries ,
95- below : belowSeries ,
96- } ;
87+ return allSeries ;
9788 } ,
9889 //Expect warning because of complex dependency
9990 // eslint-disable-next-line react-hooks/exhaustive-deps
10091 [ JSON . stringify ( nodeAddresses ) ] ,
10192 ) ,
10293 } ) ;
10394
104- // Register series names for symmetrical chart (above + below series)
105- useEffect ( ( ) => {
106- if ( series && ( series . above ?. length > 0 || series . below ?. length > 0 ) ) {
107- const aboveNames = series . above ?. map ( ( s ) => s . resource ) || [ ] ;
108- const belowNames = series . below ?. map ( ( s ) => s . resource ) || [ ] ;
109- const allSeriesNames = [ ...aboveNames , ...belowNames ] ;
110- register ( chartId , allSeriesNames ) ;
111- }
112- } , [ chartId , register , series ] ) ;
95+ useChartLegendRegistration ( { chartId, series, isSymmetrical : true } ) ;
11396
11497 return (
11598 < LineTimeSerieChart
11699 series = { {
117100 above : series . above ,
118101 below : series . below ,
119102 } }
120- height = { 150 }
103+ height = { HEIGHT_SYMMETRICAL_CHART }
121104 unitRange = { UNIT_RANGE_BS }
122105 interval = { interval }
123106 duration = { duration }
0 commit comments