Skip to content

Commit

Permalink
[front]fix date format(#7921)
Browse files Browse the repository at this point in the history
  • Loading branch information
CelineSebe committed Aug 20, 2024
1 parent 85bce40 commit 3ae3b5f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion opencti-platform/opencti-front/src/utils/Charts.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as C from '@mui/material/colors';
import { resolveLink } from './Entity';
import { truncate } from './String';
import { dateFormat, timestamp } from './Time';

const colors = (temp) => [
C.red[temp],
Expand Down Expand Up @@ -31,6 +32,7 @@ const toolbarOptions = {
columnDelimiter: ',',
headerCategory: 'category',
headerValue: 'value',
// eslint-disable-next-line @typescript-eslint/no-shadow
dateFormatter(timestamp) {
return new Date(timestamp).toDateString();
},
Expand Down Expand Up @@ -524,7 +526,17 @@ export const horizontalBarsChartOptions = (
show: stackType !== '100%',
labels: {
show: stackType !== '100%',
formatter: (value) => (yFormatter && typeof value === 'number' ? yFormatter(value) : value),
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;
},
style: {
fontFamily: '"IBM Plex Sans", sans-serif',
},
Expand Down

0 comments on commit 3ae3b5f

Please sign in to comment.