1- import  React  from  'react' ; 
1+ import  React ,   {   useMemo   }  from  'react' ; 
22import  {  useSeriesContext  }  from  '@lg-charts/series-provider' ; 
3- import  _  from  'lodash' ; 
43
54import  {  useDarkMode  }  from  '@leafygreen-ui/leafygreen-provider' ; 
65
@@ -11,40 +10,39 @@ import { SeriesProps } from '../Series.types';
1110
1211export  type  LineProps  =  SeriesProps ; 
1312
14- const  defaultLineOptions : EChartLineSeriesOption  =  { 
15-   type : 'line' , 
16-   showSymbol : false , 
17-   symbol : 'circle' , 
18-   clip : false , 
19-   symbolSize : 7 , 
20-   emphasis : { 
21-     focus : 'series' , 
22-   } , 
23-   blur : { 
24-     lineStyle : { 
25-       opacity : 0.5 , 
13+ function  getDefaultLineOptions ( seriesColor : string ) : EChartLineSeriesOption  { 
14+   return  { 
15+     type : 'line' , 
16+     showSymbol : false , 
17+     symbol : 'circle' , 
18+     clip : false , 
19+     symbolSize : 7 , 
20+     emphasis : { 
21+       focus : 'series' , 
22+     } , 
23+     blur : { 
24+       lineStyle : { 
25+         opacity : 0.5 , 
26+       } , 
27+     } , 
28+     itemStyle : { 
29+       color : seriesColor  ||  undefined 
2630    } , 
27-   } , 
28-   lineStyle : { 
29-     width : 1 , 
30-   } , 
31- } ; 
31+     lineStyle : { 
32+       color : seriesColor  ||  undefined , 
33+       width : 1 , 
34+     } 
35+   } 
36+ } 
3237
3338export  function  Line ( props : LineProps )  { 
3439  const  {  getColor }  =  useSeriesContext ( ) ; 
3540  const  {  theme }  =  useDarkMode ( ) ; 
36-   const  color  =  getColor ( props . name ,  theme ) ; 
37-   const  colorOverrides : EChartLineSeriesOption  =  { 
38-     lineStyle : {  color : color  ||  undefined  } , 
39-     itemStyle : {  color : color  ||  undefined  } , 
40-   } ; 
41- 
42-   const  options : EChartSeriesOption  =  _ . merge ( 
43-     { } , 
44-     defaultLineOptions , 
45-     props , 
46-     colorOverrides , 
47-   ) ; 
41+ 
42+   const  options : EChartSeriesOption  =  useMemo ( ( )  =>  ( { 
43+     ...getDefaultLineOptions ( getColor ( props . name ,  theme ) ) , 
44+     ...props 
45+   } ) ,  [ props ,  getColor ,  theme ] ) ; 
4846
4947  return  < Series  { ...options }  /> ; 
5048} 
0 commit comments