@@ -160,34 +160,34 @@ const ComposedChart: FC<ComposedChartProps> = forwardRef((props: ComposedChartPr
160160 ( payload , eventOrIndex , event ) => {
161161 if ( payload . name ) {
162162 typeof onDataPointClick === 'function' &&
163- onDataPointClick (
164- enrichEventWithDetails ( event ?? eventOrIndex , {
165- value : payload . value . length ? payload . value [ 1 ] - payload . value [ 0 ] : payload . value ,
166- dataIndex : payload . index ?? eventOrIndex ,
167- dataKey : payload . value . length
168- ? Object . keys ( payload ) . filter ( ( key ) =>
169- payload . value . length
170- ? payload [ key ] === payload . value [ 1 ] - payload . value [ 0 ]
171- : payload [ key ] === payload . value && key !== 'value'
172- ) [ 0 ]
173- : payload . dataKey ??
174- Object . keys ( payload ) . find ( ( key ) => payload [ key ] === payload . value && key !== 'value' ) ,
175- payload : payload . payload
176- } )
177- ) ;
163+ onDataPointClick (
164+ enrichEventWithDetails ( event ?? eventOrIndex , {
165+ value : payload . value . length ? payload . value [ 1 ] - payload . value [ 0 ] : payload . value ,
166+ dataIndex : payload . index ?? eventOrIndex ,
167+ dataKey : payload . value . length
168+ ? Object . keys ( payload ) . filter ( ( key ) =>
169+ payload . value . length
170+ ? payload [ key ] === payload . value [ 1 ] - payload . value [ 0 ]
171+ : payload [ key ] === payload . value && key !== 'value'
172+ ) [ 0 ]
173+ : payload . dataKey ??
174+ Object . keys ( payload ) . find ( ( key ) => payload [ key ] === payload . value && key !== 'value' ) ,
175+ payload : payload . payload
176+ } )
177+ ) ;
178178 } else {
179179 typeof onDataPointClick === 'function' &&
180- onDataPointClick (
181- enrichEventWithDetails (
182- { } ,
183- {
184- value : eventOrIndex . value ,
185- dataKey : eventOrIndex . dataKey ,
186- dataIndex : eventOrIndex . index ,
187- payload : eventOrIndex . payload
188- }
189- )
190- ) ;
180+ onDataPointClick (
181+ enrichEventWithDetails (
182+ { } ,
183+ {
184+ value : eventOrIndex . value ,
185+ dataKey : eventOrIndex . dataKey ,
186+ dataIndex : eventOrIndex . index ,
187+ payload : eventOrIndex . payload
188+ }
189+ )
190+ ) ;
191191 }
192192 } ,
193193 [ onDataPointClick ]
@@ -211,7 +211,7 @@ const ComposedChart: FC<ComposedChartProps> = forwardRef((props: ComposedChartPr
211211 } ;
212212
213213 const Placeholder = useCallback ( ( ) => {
214- return < ComposedChartPlaceholder layout = { layout } measures = { measures } /> ;
214+ return < ComposedChartPlaceholder layout = { layout } measures = { measures } /> ;
215215 } , [ layout , measures ] ) ;
216216 return (
217217 < ChartContainer
@@ -224,50 +224,55 @@ const ComposedChart: FC<ComposedChartProps> = forwardRef((props: ComposedChartPr
224224 tooltip = { tooltip }
225225 slot = { slot }
226226 >
227- < ComposedChartLib margin = { marginChart } data = { dataset } layout = { layout } >
227+ < ComposedChartLib
228+ margin = { marginChart }
229+ data = { dataset }
230+ layout = { layout }
231+ className = { typeof onDataPointClick === 'function' ? 'has-click-handler' : undefined }
232+ >
228233 < CartesianGrid
229234 vertical = { chartConfig . gridVertical }
230235 horizontal = { chartConfig . gridHorizontal }
231236 stroke = { chartConfig . gridStroke }
232237 />
233238 { chartConfig . xAxisVisible &&
234- dimensions . map ( ( dimension , index ) => {
235- let AxisComponent ;
236- const axisProps : any = {
237- dataKey : dimension . accessor ,
238- interval : dimension ?. interval ?? ( isBigDataSet ? 'preserveStart' : 0 ) ,
239- tickLine : index < 1 ,
240- axisLine : index < 1 ,
241- allowDuplicatedCategory : index === 0 ,
242- scale : dimensions . length === 1 ? 'band' : 'auto'
243- } ;
239+ dimensions . map ( ( dimension , index ) => {
240+ let AxisComponent ;
241+ const axisProps : any = {
242+ dataKey : dimension . accessor ,
243+ interval : dimension ?. interval ?? ( isBigDataSet ? 'preserveStart' : 0 ) ,
244+ tickLine : index < 1 ,
245+ axisLine : index < 1 ,
246+ allowDuplicatedCategory : index === 0 ,
247+ scale : dimensions . length === 1 ? 'band' : 'auto'
248+ } ;
244249
245- if ( layout === 'vertical' ) {
246- axisProps . type = 'category' ;
247- axisProps . tick = < YAxisTicks config = { dimension } /> ;
248- axisProps . yAxisId = index ;
249- axisProps . width = yAxisWidth ;
250- AxisComponent = YAxis ;
251- } else {
252- axisProps . dataKey = dimension . accessor ;
253- axisProps . tick = < XAxisTicks config = { dimension } /> ;
254- axisProps . xAxisId = index ;
255- axisProps . height = xAxisHeights [ index ] ;
256- AxisComponent = XAxis ;
257- }
250+ if ( layout === 'vertical' ) {
251+ axisProps . type = 'category' ;
252+ axisProps . tick = < YAxisTicks config = { dimension } /> ;
253+ axisProps . yAxisId = index ;
254+ axisProps . width = yAxisWidth ;
255+ AxisComponent = YAxis ;
256+ } else {
257+ axisProps . dataKey = dimension . accessor ;
258+ axisProps . tick = < XAxisTicks config = { dimension } /> ;
259+ axisProps . xAxisId = index ;
260+ axisProps . height = xAxisHeights [ index ] ;
261+ AxisComponent = XAxis ;
262+ }
258263
259- return < AxisComponent key = { dimension . accessor } { ...axisProps } /> ;
260- } ) }
264+ return < AxisComponent key = { dimension . accessor } { ...axisProps } /> ;
265+ } ) }
261266 { layout === 'horizontal' && (
262267 < YAxis
263268 { ...measureAxisProps }
264269 yAxisId = "primary"
265270 width = { yAxisWidth }
266- tick = { < YAxisTicks config = { primaryMeasure } /> }
271+ tick = { < YAxisTicks config = { primaryMeasure } /> }
267272 />
268273 ) }
269274 { layout === 'vertical' && (
270- < XAxis { ...measureAxisProps } xAxisId = "primary" type = "number" tick = { < XAxisTicks config = { primaryMeasure } /> } />
275+ < XAxis { ...measureAxisProps } xAxisId = "primary" type = "number" tick = { < XAxisTicks config = { primaryMeasure } /> } />
271276 ) }
272277
273278 { chartConfig . secondYAxis ?. dataKey && layout === 'horizontal' && (
@@ -301,7 +306,7 @@ const ComposedChart: FC<ComposedChartProps> = forwardRef((props: ComposedChartPr
301306 xAxisId = { layout === 'vertical' ? 'primary' : undefined }
302307 />
303308 ) }
304- < Tooltip cursor = { tooltipFillOpacity } formatter = { tooltipValueFormatter } contentStyle = { tooltipContentStyle } />
309+ < Tooltip cursor = { tooltipFillOpacity } formatter = { tooltipValueFormatter } contentStyle = { tooltipContentStyle } />
305310 { ! noLegend && (
306311 < Legend
307312 verticalAlign = { chartConfig . legendPosition }
@@ -360,7 +365,7 @@ const ComposedChart: FC<ComposedChartProps> = forwardRef((props: ComposedChartPr
360365 name = { element . label ?? element . accessor }
361366 label = {
362367 isBigDataSet ? null : (
363- < ChartDataLabel config = { element } chartType = { element . type } position = { labelPosition } />
368+ < ChartDataLabel config = { element } chartType = { element . type } position = { labelPosition } />
364369 )
365370 }
366371 stroke = { element . color ?? `var(--sapChart_OrderedColor_${ ( index % 11 ) + 1 } )` }
0 commit comments