11import { useCallback , useEffect , useReducer , useRef } from 'react' ;
22
3- import { RawSerieData , YagrPlugin , YagrWidgetData } from '@gravity-ui/chartkit/yagr' ;
3+ import { YagrPlugin , YagrSeriesData , YagrWidgetData } from '@gravity-ui/chartkit/yagr' ;
44import ChartKit , { settings } from '@gravity-ui/chartkit' ;
55
66import type { IResponseError } from '../../types/api/error' ;
77import type { TimeFrame } from '../../utils/timeframes' ;
88import { useAutofetcher } from '../../utils/hooks' ;
99
10- import { COLORS } from '../../utils/versions' ;
1110import { cn } from '../../utils/cn' ;
1211
1312import { Loader } from '../Loader' ;
@@ -30,6 +29,7 @@ import {
3029 setChartDataWasNotLoaded ,
3130 setChartError ,
3231} from './reducer' ;
32+ import { colorToRGBA , colors } from './colors' ;
3333import i18n from './i18n' ;
3434
3535import './MetricChart.scss' ;
@@ -47,13 +47,19 @@ const prepareWidgetData = (
4747
4848 const isDataEmpty = ! data . metrics . length ;
4949
50- const graphs : RawSerieData [ ] = data . metrics . map ( ( metric , index ) => {
50+ const graphs : YagrSeriesData [ ] = data . metrics . map ( ( metric , index ) => {
51+ const lineColor = metric . color || colors [ index ] ;
52+ const color = colorToRGBA ( lineColor , 0.1 ) ;
53+
5154 return {
5255 id : metric . target ,
5356 name : metric . title || metric . target ,
54- color : metric . color || COLORS [ index ] ,
5557 data : metric . data ,
5658 formatter : defaultDataFormatter ,
59+
60+ lineColor,
61+ color,
62+ legendColorKey : 'lineColor' ,
5763 } ;
5864 } ) ;
5965
@@ -71,7 +77,8 @@ const prepareWidgetData = (
7177 padding : isDataEmpty ? [ 10 , 0 , 10 , 0 ] : undefined ,
7278 } ,
7379 series : {
74- type : 'line' ,
80+ type : 'area' ,
81+ lineWidth : 1.5 ,
7582 } ,
7683 select : {
7784 zoom : false ,
@@ -209,7 +216,7 @@ export const MetricChart = ({
209216 dispatch ( setChartError ( err as IResponseError ) ) ;
210217 }
211218 } ,
212- [ metrics , timeFrame , width ] ,
219+ [ database , metrics , timeFrame , width ] ,
213220 ) ;
214221
215222 useAutofetcher ( fetchChartData , [ fetchChartData ] , autorefresh ) ;
0 commit comments