diff --git a/opencti-platform/opencti-front/src/components/dashboard/WidgetHorizontalBars.tsx b/opencti-platform/opencti-front/src/components/dashboard/WidgetHorizontalBars.tsx index c370f139a8514..cb564954da79a 100644 --- a/opencti-platform/opencti-front/src/components/dashboard/WidgetHorizontalBars.tsx +++ b/opencti-platform/opencti-front/src/components/dashboard/WidgetHorizontalBars.tsx @@ -6,6 +6,7 @@ import { ApexOptions } from 'apexcharts'; import { horizontalBarsChartOptions } from '../../utils/Charts'; import { simpleNumberFormat } from '../../utils/Number'; import type { Theme } from '../Theme'; +import { dateFormat, timestamp } from '../../utils/Time'; interface WidgetHorizontalBarsProps { series: ApexAxisChartSeries @@ -36,13 +37,27 @@ const WidgetHorizontalBars = ({ const theme = useTheme(); const navigate = useNavigate(); + const getFormattedValue = (value: any) => { + if (typeof value === 'number') { + simpleNumberFormat(value); + } + const timestampInMs = parseInt(value, 10); + + if (!Number.isNaN(timestampInMs)) { + const convertedDate = timestamp(timestampInMs); + const date = dateFormat(convertedDate, 'DD-MM-YYYY'); + if (date) return date; + } + return value; + }; + return ( [ C.red[temp], @@ -526,17 +525,7 @@ export const horizontalBarsChartOptions = ( show: stackType !== '100%', labels: { show: stackType !== '100%', - formatter: (value) => { - if (yFormatter && typeof value === 'number') { - return yFormatter(value); - } - if (typeof value === 'string' && value.length === 15) { - const timestampInMs = parseInt(value, 10); - const convertedDate = timestamp(timestampInMs); - return dateFormat(convertedDate, 'DD-MM-YYYY'); - } - return value; - }, + formatter: (value) => (yFormatter ? yFormatter(value) : value), style: { fontFamily: '"IBM Plex Sans", sans-serif', },