@@ -21,15 +21,14 @@ import {
21
21
import React , { useEffect , useRef , useState } from 'react' ;
22
22
import { MonitorMetricsType } from './MonitorMetricsType' ;
23
23
import { ApiError , Metric , MonitorService , Response } from '../../../xpanse-api/generated' ;
24
- import * as echarts from 'echarts/core' ;
25
24
import {
26
25
fetchMonitorMetricDataTimeInterval ,
27
26
fetchOnlyLastKnownMonitorMetricDataTimeInterval ,
28
27
monitorMetricQueueSize ,
29
28
} from '../../utils/constants' ;
30
- import moment from 'moment' ;
31
29
import { MetricOptionDataByChartsPerRow } from './MetricOptionDataByChartsPerRow' ;
32
30
import { useQuery } from '@tanstack/react-query' ;
31
+ import { EChartsCoreOption } from 'echarts' ;
33
32
34
33
export const MonitorChart = ( {
35
34
serviceId,
@@ -54,7 +53,7 @@ export const MonitorChart = ({
54
53
) => void ;
55
54
getIsLoading : ( isLoading : boolean ) => void ;
56
55
getOptionLength : ( optionLength : number ) => void ;
57
- } ) : JSX . Element => {
56
+ } ) : React . JSX . Element => {
58
57
const [ activeMonitorMetricType , setActiveMonitorMetricType ] = useState < string > (
59
58
Metric . monitorResourceType . CPU . valueOf ( )
60
59
) ;
@@ -68,7 +67,7 @@ export const MonitorChart = ({
68
67
const [ monitorMetricsQueue , setMonitorMetricsQueue ] = useState < MetricQueueParams [ ] > ( [ ] ) ;
69
68
70
69
const [ chartsTitle , setChartsTitle ] = useState < { Id : string ; metricTitle : string ; metricSubTitle : string } [ ] > ( [ ] ) ;
71
- const [ options , setOptions ] = useState < echarts . EChartsCoreOption [ ] > ( [ ] ) ;
70
+ const [ options , setOptions ] = useState < EChartsCoreOption [ ] > ( [ ] ) ;
72
71
73
72
const tipMessageInfo = useRef < string > ( '' ) ;
74
73
const tipDescriptionInfo = useRef < string [ ] > ( [ ] ) ;
@@ -96,7 +95,9 @@ export const MonitorChart = ({
96
95
const onlyLastKnownMetricQueryFn = ( ) =>
97
96
MonitorService . getMetrics ( serviceId , undefined , undefined , undefined , undefined , undefined , true ) ;
98
97
99
- const onlyLastKnownMetricQuery = useQuery ( onlyLastKnownMetricQueryKey , onlyLastKnownMetricQueryFn , {
98
+ const onlyLastKnownMetricQuery = useQuery ( {
99
+ queryKey : onlyLastKnownMetricQueryKey ,
100
+ queryFn : onlyLastKnownMetricQueryFn ,
100
101
refetchInterval : isRefreshOnlyLastKnownMetric ? fetchOnlyLastKnownMonitorMetricDataTimeInterval : false ,
101
102
refetchIntervalInBackground : isRefreshOnlyLastKnownMetric ,
102
103
refetchOnWindowFocus : false ,
@@ -117,7 +118,9 @@ export const MonitorChart = ({
117
118
false
118
119
) ;
119
120
120
- const monitorMetricQuery = useQuery ( monitorMetricQueryKey , monitorMetricQueryFn , {
121
+ const monitorMetricQuery = useQuery ( {
122
+ queryKey : monitorMetricQueryKey ,
123
+ queryFn : monitorMetricQueryFn ,
121
124
refetchInterval : isRefreshMonitorMetric ? fetchMonitorMetricDataTimeInterval : false ,
122
125
refetchIntervalInBackground : isRefreshMonitorMetric ,
123
126
refetchOnWindowFocus : false ,
@@ -294,7 +297,7 @@ export const MonitorChart = ({
294
297
295
298
const currentMetricProps : Map < string , MetricProps [ ] > = getCurrentMetricProps ( metricProps ) ;
296
299
const currentChartsTitle : { Id : string ; metricTitle : string ; metricSubTitle : string } [ ] = [ ] ;
297
- const currentOptions : echarts . EChartsCoreOption [ ] = [ ] ;
300
+ const currentOptions : EChartsCoreOption [ ] = [ ] ;
298
301
299
302
currentMetricProps . forEach ( ( metricProps , vmId ) => {
300
303
currentChartsTitle . push ( {
@@ -308,7 +311,7 @@ export const MonitorChart = ({
308
311
) ,
309
312
metricSubTitle : metricProps [ 0 ] . vmName ,
310
313
} ) ;
311
- const option : echarts . EChartsCoreOption = {
314
+ const option : EChartsCoreOption = {
312
315
tooltip : {
313
316
trigger : 'axis' ,
314
317
position : function ( pt : number [ ] ) {
@@ -320,11 +323,6 @@ export const MonitorChart = ({
320
323
show : true ,
321
324
} ,
322
325
} ,
323
- valueFormatter : function ( params : number ) {
324
- return `${ params } ${
325
- metricProps [ 0 ] . unit === Metric . unit . PERCENTAGE ? '%' : metricProps [ 0 ] . unit . valueOf ( )
326
- } `;
327
- } ,
328
326
} ,
329
327
xAxis : {
330
328
type : 'time' ,
@@ -333,11 +331,6 @@ export const MonitorChart = ({
333
331
show : true ,
334
332
fontSize : 10 ,
335
333
rotate : 40 ,
336
- formatter : function ( value : Date ) {
337
- const date = moment ( value ) . format ( 'YYYY-MM-DD' ) ;
338
- const time = moment ( value ) . format ( 'HH:mm:ss' ) ;
339
- return date + '\n' + time ;
340
- } ,
341
334
} ,
342
335
axisTick : {
343
336
show : true ,
0 commit comments