Skip to content

ARTESCA-14587: new line time serie chart component #817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: development/1.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 160 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
"react-virtualized": "9.22.3",
"react-virtualized-auto-sizer": "^1.0.24",
"react-window": "^1.8.6",
"recharts": "^2.15.1",
"styled-components": "^5.2.1",
"styled-system": "^5.1.5",
"vega": "^5.17.3",
Expand Down
24 changes: 24 additions & 0 deletions src/lib/components/date/FormattedDateTime.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,28 @@ describe('FormatttedDateTime', () => {
//V
expect(screen.getByText('2022-12-12 11:57:26')).toBeInTheDocument();
});

it('should display the date in the expected format of the xaxis tick in the chart', () => {
//S
render(
<FormattedDateTime
format="day-month-abbreviated-hour-minute"
value={new Date('2022-10-06T18:33:00Z')}
/>,
);
//V
expect(screen.getByText('6 Oct 18:33')).toBeInTheDocument();
});

it('should display the date in the expected format of date in the chart', () => {
//S
render(
<FormattedDateTime
format="day-month-abbreviated-hour-minute-second"
value={new Date('2022-10-06T18:33:00Z')}
/>,
);
//V
expect(screen.getByText('6 Oct 18:33:00')).toBeInTheDocument();
});
});
38 changes: 36 additions & 2 deletions src/lib/components/date/FormattedDateTime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,36 @@ export const TIME_FORMATER = Intl.DateTimeFormat('en-GB', {
minute: '2-digit',
});

export const DAY_MONTH_ABBREVIATED_HOUR_MINUTE_SECOND = Intl.DateTimeFormat(
'en-GB',
{
day: 'numeric',
month: 'short',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: false,
},
);

export const DAY_MONTH_ABBREVIATED_HOUR_MINUTE = Intl.DateTimeFormat('en-GB', {
day: 'numeric',
month: 'short',
hour: '2-digit',
minute: '2-digit',
hour12: false,
});

type FormattedDateTimeProps = {
format:
| 'date'
| 'date-time'
| 'date-time-second'
| 'time'
| 'time-second'
| 'relative';
| 'relative'
| 'day-month-abbreviated-hour-minute'
| 'day-month-abbreviated-hour-minute-second';
value: Date;
};

Expand Down Expand Up @@ -143,7 +165,19 @@ export const FormattedDateTime = ({
few seconds ago
</Tooltip>
);
//TO FINISH
case 'day-month-abbreviated-hour-minute':
return (
<>{DAY_MONTH_ABBREVIATED_HOUR_MINUTE.format(value).replace(',', '')}</>
);
case 'day-month-abbreviated-hour-minute-second':
return (
<>
{DAY_MONTH_ABBREVIATED_HOUR_MINUTE_SECOND.format(value).replace(
',',
'',
)}
</>
);
default:
return <></>;
}
Expand Down
Loading
Loading