1
1
'use client' ;
2
2
3
- import { ThemingParameters } from '@ui5/webcomponents-react-base' ;
3
+ import { ThemingParameters , useStylesheet } from '@ui5/webcomponents-react-base' ;
4
+ import { clsx } from 'clsx' ;
4
5
import type { CSSProperties } from 'react' ;
5
6
import { forwardRef , useId } from 'react' ;
6
7
import type { TooltipProps , YAxisProps } from 'recharts' ;
@@ -13,6 +14,7 @@ import type { IChartDimension } from '../../interfaces/IChartDimension.js';
13
14
import type { IChartMeasure } from '../../interfaces/IChartMeasure.js' ;
14
15
import { defaultFormatter } from '../../internal/defaults.js' ;
15
16
import { ComposedChart } from '../ComposedChart/index.js' ;
17
+ import { classNames , content } from './ColumnChartWithTrend.module.css.js' ;
16
18
import { ColumnChartWithTrendPlaceholder } from './Placeholder.js' ;
17
19
18
20
interface MeasureConfig extends IChartMeasure {
@@ -111,9 +113,7 @@ const ColumnChartWithTrend = forwardRef<HTMLDivElement, ColumnChartWithTrendProp
111
113
loading,
112
114
loadingDelay,
113
115
dataset,
114
- style,
115
116
className,
116
- slot,
117
117
onClick,
118
118
noLegend,
119
119
noAnimation,
@@ -122,9 +122,10 @@ const ColumnChartWithTrend = forwardRef<HTMLDivElement, ColumnChartWithTrendProp
122
122
ChartPlaceholder,
123
123
...rest
124
124
} = props ;
125
-
126
125
const syncId = useId ( ) ;
127
126
127
+ useStylesheet ( content , ColumnChartWithTrend . displayName ) ;
128
+
128
129
const chartConfig : ColumnChartWithTrendProps [ 'chartConfig' ] = {
129
130
yAxisVisible : false ,
130
131
xAxisVisible : true ,
@@ -165,25 +166,19 @@ const ColumnChartWithTrend = forwardRef<HTMLDivElement, ColumnChartWithTrendProp
165
166
const { chartConfig : _0 , dimensions : _1 , measures : _2 , ...propsWithoutOmitted } = rest ;
166
167
167
168
return (
168
- < div
169
- ref = { ref }
170
- style = { { display : 'flex' , flexDirection : 'column' , height : style ?. height , width : style ?. width , ...style } }
171
- className = { className }
172
- slot = { slot }
173
- { ...propsWithoutOmitted }
174
- >
169
+ < div ref = { ref } className = { clsx ( className , classNames . container ) } { ...propsWithoutOmitted } >
175
170
{ dataset ?. length !== 0 && (
176
171
< ComposedChart
177
- className = {
178
- typeof onDataPointClick === 'function' || typeof onClick === 'function' ? 'has-click-handler' : undefined
179
- }
172
+ className = { clsx (
173
+ typeof onDataPointClick === 'function' || typeof onClick === 'function' ? 'has-click-handler' : undefined ,
174
+ classNames . trendContainer
175
+ ) }
180
176
tooltipConfig = { lineTooltipConfig }
181
177
noAnimation = { noAnimation }
182
178
loading = { loading }
183
179
loadingDelay = { loadingDelay }
184
180
onClick = { onClick }
185
181
syncId = { syncId }
186
- style = { { ...style , height : `calc(${ style ?. height } * 0.2)` } }
187
182
dataset = { dataset }
188
183
measures = { lineMeasures }
189
184
dimensions = { dimensions }
@@ -201,6 +196,10 @@ const ColumnChartWithTrend = forwardRef<HTMLDivElement, ColumnChartWithTrendProp
201
196
/>
202
197
) }
203
198
< ComposedChart
199
+ className = { clsx (
200
+ typeof onDataPointClick === 'function' || typeof onClick === 'function' ? 'has-click-handler' : undefined ,
201
+ classNames . chartContainer
202
+ ) }
204
203
onLegendClick = { onLegendClick }
205
204
tooltipConfig = { columnTooltipConfig }
206
205
noAnimation = { noAnimation }
@@ -215,10 +214,6 @@ const ColumnChartWithTrend = forwardRef<HTMLDivElement, ColumnChartWithTrendProp
215
214
measures = { columnMeasures }
216
215
dimensions = { dimensions }
217
216
chartConfig = { chartConfig }
218
- style = { { ...style , height : `calc(${ style ?. height } * ${ dataset ?. length !== 0 ? 0.8 : 1 } )` } }
219
- className = {
220
- typeof onDataPointClick === 'function' || typeof onClick === 'function' ? 'has-click-handler' : undefined
221
- }
222
217
/>
223
218
</ div >
224
219
) ;
0 commit comments