forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] Explain log rate spikes: Fix brush issues. (elastic#138113) (ela…
…stic#138134) - Fixes overlapping brush badges. - Adds missing tooltips to brush badges. (cherry picked from commit 9512635) Co-authored-by: Walter Rafelsberger <[email protected]>
- Loading branch information
1 parent
9e45b6b
commit f213348
Showing
3 changed files
with
116 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...ugins/aiops/public/components/document_count_content/document_count_chart/brush_badge.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React, { FC } from 'react'; | ||
|
||
import { EuiBadge, EuiText, EuiToolTip } from '@elastic/eui'; | ||
// @ts-ignore | ||
import { formatDate } from '@elastic/eui/lib/services/format'; | ||
|
||
const DATE_FORMAT = 'YYYY-MM-DD'; | ||
const TIME_FORMAT = 'HH:mm:ss'; | ||
|
||
interface BrushBadgeProps { | ||
label: string; | ||
marginLeft: number; | ||
timestampFrom: number; | ||
timestampTo: number; | ||
width: number; | ||
} | ||
|
||
export const BrushBadge: FC<BrushBadgeProps> = ({ | ||
label, | ||
marginLeft, | ||
timestampFrom, | ||
timestampTo, | ||
width, | ||
}) => { | ||
// If "from" and "to" are on the same day, we skip displaying the date twice. | ||
const dateFrom = formatDate(timestampFrom, DATE_FORMAT); | ||
const dateTo = formatDate(timestampTo, DATE_FORMAT); | ||
const timeFrom = formatDate(timestampFrom, TIME_FORMAT); | ||
const timeTo = formatDate(timestampTo, TIME_FORMAT); | ||
|
||
return ( | ||
<div | ||
css={{ | ||
position: 'absolute', | ||
'margin-left': `${marginLeft}px`, | ||
}} | ||
> | ||
<EuiToolTip | ||
content={ | ||
<EuiText size="xs"> | ||
{dateFrom} {timeFrom} -{' '} | ||
{dateFrom !== dateTo && ( | ||
<> | ||
<br /> | ||
{dateTo}{' '} | ||
</> | ||
)} | ||
{timeTo} | ||
</EuiText> | ||
} | ||
position="top" | ||
> | ||
<EuiBadge css={{ width, 'text-align': 'center' }}>{label}</EuiBadge> | ||
</EuiToolTip> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters