@@ -190,6 +190,8 @@ export const getDefaultOptions = ({
190190 xScaleTitle,
191191 yScaleTitle,
192192 yScaleTickFormat,
193+ xScaleTickFormat,
194+ xAxisLabels,
193195 } = chartProps
194196 const baseOptions : ChartOptions = {
195197 responsive : true ,
@@ -253,28 +255,42 @@ export const getDefaultOptions = ({
253255 } ,
254256 } satisfies ScaleOptions < 'linear' >
255257
256- const ticksWithCallback = {
257- ...commonScaleConfig . ticks ,
258- callback : ( value ) => yScaleTickFormat ( Number ( value ) ) ,
259- } satisfies ScaleOptions < 'linear' > [ 'ticks' ]
260-
261258 const commonXScaleConfig = {
262259 ...commonScaleConfig ,
263260 max : xAxisMax ,
264261 title : getScaleTickTitleConfig ( xScaleTitle , appTheme ) ,
265- ...( typeof yScaleTickFormat === 'function' && type === 'stackedBarHorizontal'
266- ? { ticks : ticksWithCallback }
267- : { } ) ,
262+ ticks : {
263+ ...commonScaleConfig . ticks ,
264+ ...( ( type !== 'stackedBarHorizontal' && typeof xScaleTickFormat === 'function' ) ||
265+ ( type === 'stackedBarHorizontal' && typeof yScaleTickFormat === 'function' )
266+ ? {
267+ callback :
268+ type === 'stackedBarHorizontal'
269+ ? ( value , index ) => yScaleTickFormat ( Number ( value ) , index )
270+ : ( _ , index ) => xScaleTickFormat ( xAxisLabels [ index ] , index ) ,
271+ }
272+ : { } ) ,
273+ autoSkip : false ,
274+ } ,
268275 } satisfies ScaleOptions < 'linear' >
269276
270277 const commonYScaleConfig = {
271278 ...commonScaleConfig ,
272279 max : yAxisMax ,
273280 title : getScaleTickTitleConfig ( yScaleTitle , appTheme ) ,
274281 // for stackedBarHorizon
275- ...( typeof yScaleTickFormat === 'function' && type !== 'stackedBarHorizontal'
276- ? { ticks : ticksWithCallback }
277- : { } ) ,
282+ ticks : {
283+ ...commonScaleConfig . ticks ,
284+ ...( ( type === 'stackedBarHorizontal' && typeof xScaleTickFormat === 'function' ) ||
285+ ( type !== 'stackedBarHorizontal' && typeof yScaleTickFormat === 'function' )
286+ ? {
287+ callback :
288+ type !== 'stackedBarHorizontal'
289+ ? ( value , index ) => yScaleTickFormat ( Number ( value ) , index )
290+ : ( _ , index ) => xScaleTickFormat ( xAxisLabels [ index ] , index ) ,
291+ }
292+ : { } ) ,
293+ } ,
278294 } satisfies ScaleOptions < 'linear' >
279295
280296 switch ( type ) {
@@ -555,7 +571,7 @@ export const buildChartTooltipFromContext = ({
555571 < div className = "flexbox-col dc__gap-2" >
556572 { titleLines . map ( ( titleLine , index ) => (
557573 // eslint-disable-next-line react/no-array-index-key
558- < h6 key = { index } className = "m-0 fs-12 fw-6 lh-20 dc__truncate " >
574+ < h6 key = { index } className = "m-0 fs-12 fw-6 lh-20 dc__word-break-all " >
559575 { titleLine }
560576 </ h6 >
561577 ) ) }
0 commit comments