@@ -7,7 +7,7 @@ import { XAxisTicks } from '@ui5/webcomponents-react-charts/lib/components/XAxis
77import { YAxisTicks } from '@ui5/webcomponents-react-charts/lib/components/YAxisTicks' ;
88import { ChartContainer } from '@ui5/webcomponents-react-charts/lib/next/ChartContainer' ;
99import { useLegendItemClick } from '@ui5/webcomponents-react-charts/lib/useLegendItemClick' ;
10- import React , { FC , forwardRef , Ref , useCallback , useState } from 'react' ;
10+ import React , { FC , forwardRef , Ref , useCallback , useState , useMemo } from 'react' ;
1111import {
1212 Area ,
1313 Bar ,
@@ -28,7 +28,7 @@ import { useTooltipFormatter } from '../../hooks/useTooltipFormatter';
2828import { IChartDimension } from '../../interfaces/IChartDimension' ;
2929import { IChartMeasure } from '../../interfaces/IChartMeasure' ;
3030import { RechartBaseProps } from '../../interfaces/RechartBaseProps' ;
31- import { tickLineConfig , tooltipContentStyle } from '../../internal/staticProps' ;
31+ import { tickLineConfig , tooltipContentStyle , tooltipFillOpacity } from '../../internal/staticProps' ;
3232
3333const dimensionDefaults = {
3434 formatter : ( d ) => d
@@ -116,29 +116,6 @@ const ComposedChart: FC<ComposedChartProps> = forwardRef((props: ComposedChartPr
116116 noLegend = false ,
117117 onLegendClick,
118118 layout = 'horizontal' ,
119- chartConfig = {
120- margin : { } ,
121- yAxisVisible : false ,
122- xAxisVisible : true ,
123- gridStroke : ThemingParameters . sapList_BorderColor ,
124- gridHorizontal : true ,
125- gridVertical : false ,
126- yAxisId : '' ,
127- yAxisColor : ThemingParameters . sapList_BorderColor ,
128- legendPosition : 'top' ,
129- zoomingTool : false ,
130- barGap : undefined ,
131- referenceLine : {
132- label : undefined ,
133- value : undefined ,
134- color : undefined
135- } ,
136- secondYAxis : {
137- name : undefined ,
138- dataKey : undefined ,
139- color : undefined
140- }
141- } ,
142119 style,
143120 className,
144121 tooltip,
@@ -150,6 +127,19 @@ const ComposedChart: FC<ComposedChartProps> = forwardRef((props: ComposedChartPr
150127 dataset . some ( ( { type } ) => type === 'bar' ) ? BAR_DEFAULT_PADDING : 0
151128 ) ;
152129
130+ const chartConfig = useMemo ( ( ) => {
131+ return {
132+ yAxisVisible : false ,
133+ xAxisVisible : true ,
134+ gridStroke : ThemingParameters . sapList_BorderColor ,
135+ gridHorizontal : true ,
136+ gridVertical : false ,
137+ legendPosition : 'top' ,
138+ zoomingTool : false ,
139+ ...props . chartConfig
140+ } ;
141+ } , [ props . chartConfig ] ) ;
142+
153143 const { dimensions, measures } = usePrepareDimensionsAndMeasures (
154144 props . dimensions ,
155145 props . measures ,
@@ -164,7 +154,7 @@ const ComposedChart: FC<ComposedChartProps> = forwardRef((props: ComposedChartPr
164154
165155 const dataKeys = measures . map ( ( { accessor } ) => accessor ) ;
166156 const colorSecondY = chartConfig . secondYAxis
167- ? dataKeys . findIndex ( ( key ) => key === chartConfig . secondYAxis . dataKey )
157+ ? dataKeys . findIndex ( ( key ) => key === chartConfig . secondYAxis ? .dataKey )
168158 : 0 ;
169159
170160 const onDataPointClickInternal = useCallback (
@@ -217,7 +207,7 @@ const ComposedChart: FC<ComposedChartProps> = forwardRef((props: ComposedChartPr
217207 ) ;
218208
219209 const measureAxisProps = {
220- axisLine : chartConfig . yAxisVisible ?? false ,
210+ axisLine : chartConfig . yAxisVisible ,
221211 tickLine : tickLineConfig ,
222212 tickFormatter : primaryMeasure ?. formatter ,
223213 interval : 0
@@ -259,11 +249,11 @@ const ComposedChart: FC<ComposedChartProps> = forwardRef((props: ComposedChartPr
259249 >
260250 < ComposedChartLib margin = { marginChart } data = { dataset } layout = { layout } >
261251 < CartesianGrid
262- vertical = { chartConfig . gridVertical ?? false }
252+ vertical = { chartConfig . gridVertical }
263253 horizontal = { chartConfig . gridHorizontal }
264- stroke = { chartConfig . gridStroke ?? ThemingParameters . sapList_BorderColor }
254+ stroke = { chartConfig . gridStroke }
265255 />
266- { ( chartConfig . xAxisVisible ?? true ) &&
256+ { chartConfig . xAxisVisible &&
267257 dimensions . map ( ( dimension , index ) => {
268258 let AxisComponent ;
269259 const axisProps = {
@@ -302,7 +292,7 @@ const ComposedChart: FC<ComposedChartProps> = forwardRef((props: ComposedChartPr
302292 />
303293 ) }
304294
305- { chartConfig . secondYAxis && chartConfig . secondYAxis . dataKey && layout === 'horizontal' && (
295+ { chartConfig . secondYAxis ? .dataKey && layout === 'horizontal' && (
306296 < YAxis
307297 dataKey = { chartConfig . secondYAxis . dataKey }
308298 stroke = { chartConfig . secondYAxis . color ?? `var(--sapChart_OrderedColor_${ ( colorSecondY % 11 ) + 1 } )` }
@@ -312,7 +302,7 @@ const ComposedChart: FC<ComposedChartProps> = forwardRef((props: ComposedChartPr
312302 yAxisId = "secondary"
313303 />
314304 ) }
315- { chartConfig . secondYAxis && chartConfig . secondYAxis . dataKey && layout === 'vertical' && (
305+ { chartConfig . secondYAxis ? .dataKey && layout === 'vertical' && (
316306 < XAxis
317307 dataKey = { chartConfig . secondYAxis . dataKey }
318308 stroke = { chartConfig . secondYAxis . color ?? `var(--sapChart_OrderedColor_${ ( colorSecondY % 11 ) + 1 } )` }
@@ -333,8 +323,8 @@ const ComposedChart: FC<ComposedChartProps> = forwardRef((props: ComposedChartPr
333323 xAxisId = { layout === 'vertical' ? 'primary' : undefined }
334324 />
335325 ) }
336- < Tooltip cursor = { { fillOpacity : 0.3 } } formatter = { tooltipValueFormatter } contentStyle = { tooltipContentStyle } />
337- { ! noLegend && < Legend verticalAlign = { chartConfig . legendPosition ?? 'top' } onClick = { onItemLegendClick } /> }
326+ < Tooltip cursor = { tooltipFillOpacity } formatter = { tooltipValueFormatter } contentStyle = { tooltipContentStyle } />
327+ { ! noLegend && < Legend verticalAlign = { chartConfig . legendPosition } onClick = { onItemLegendClick } /> }
338328 { measures ?. map ( ( element , index ) => {
339329 const ChartElement = ( ChartTypes [ element . type ] as any ) as FC < any > ;
340330
@@ -375,11 +365,9 @@ const ComposedChart: FC<ComposedChartProps> = forwardRef((props: ComposedChartPr
375365 }
376366
377367 if ( layout === 'vertical' ) {
378- chartElementProps . xAxisId =
379- chartConfig ?. secondYAxis ?. dataKey === element . accessor ? 'secondary' : 'primary' ;
368+ chartElementProps . xAxisId = chartConfig . secondYAxis ?. dataKey === element . accessor ? 'secondary' : 'primary' ;
380369 } else {
381- chartElementProps . yAxisId =
382- chartConfig ?. secondYAxis ?. dataKey === element . accessor ? 'secondary' : 'primary' ;
370+ chartElementProps . yAxisId = chartConfig . secondYAxis ?. dataKey === element . accessor ? 'secondary' : 'primary' ;
383371 }
384372 return (
385373 < ChartElement
0 commit comments