Skip to content

Commit

Permalink
[ML] Fix event rate chart annotation position (elastic#91899)
Browse files Browse the repository at this point in the history
  • Loading branch information
markov00 committed Feb 19, 2021
1 parent 269a633 commit a7f2e46
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export const EventRateChart: FC<Props> = ({
<OverlayRange
key={i}
overlayKey={i}
eventRateChartData={eventRateChartData}
start={range.start}
end={range.end}
color={range.color}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,18 @@

import React, { FC } from 'react';
import { EuiIcon } from '@elastic/eui';
import { RectAnnotation, LineAnnotation, AnnotationDomainTypes } from '@elastic/charts';
import { LineChartPoint } from '../../../../common/chart_loader';
import { RectAnnotation, LineAnnotation, AnnotationDomainTypes, Position } from '@elastic/charts';
import { timeFormatter } from '../../../../../../../../common/util/date_utils';

interface Props {
overlayKey: number;
eventRateChartData: LineChartPoint[];
start: number;
end: number;
color: string;
showMarker?: boolean;
}

export const OverlayRange: FC<Props> = ({
overlayKey,
eventRateChartData,
start,
end,
color,
showMarker = true,
}) => {
const maxHeight = Math.max(...eventRateChartData.map((e) => e.value));

export const OverlayRange: FC<Props> = ({ overlayKey, start, end, color, showMarker = true }) => {
return (
<>
<RectAnnotation
Expand All @@ -41,8 +30,6 @@ export const OverlayRange: FC<Props> = ({
coordinates: {
x0: start,
x1: end,
y0: 0,
y1: maxHeight,
},
},
]}
Expand All @@ -62,16 +49,16 @@ export const OverlayRange: FC<Props> = ({
opacity: 0,
},
}}
markerPosition={Position.Bottom}
hideTooltips={true}
marker={
showMarker ? (
<>
<div style={{ marginLeft: '20px' }}>
<div style={{ textAlign: 'center' }}>
<EuiIcon type="arrowUp" />
</div>
<div style={{ fontWeight: 'normal', color: '#343741' }}>{timeFormatter(start)}</div>
<div>
<div style={{ textAlign: 'center' }}>
<EuiIcon type="arrowUp" />
</div>
</>
<div style={{ fontWeight: 'normal', color: '#343741' }}>{timeFormatter(start)}</div>
</div>
) : undefined
}
/>
Expand Down

0 comments on commit a7f2e46

Please sign in to comment.