Skip to content

Commit

Permalink
[ML] Fix alignment if some annotations overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
qn895 committed Jul 14, 2021
1 parent 348273e commit 3151364
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export const AnomalyTimeline: FC<AnomalyTimelineProps> = React.memo(
tooltipService={tooltipService}
/>
)}
</MlTooltipComponent>{' '}
</MlTooltipComponent>
<EuiSpacer size="m" />
</>
) : null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,23 @@ export const SwimlaneAnnotationContainer: FC<SwimlaneAnnotationContainerProps> =

// Add annotation marker
annotationsData.forEach((d) => {
const annotationWidth = d.end_timestamp
? xScale(Math.min(d.end_timestamp, domain.max)) -
Math.max(xScale(d.timestamp), startingXPos)
: 0;

const annotationWidth = Math.max(
d.end_timestamp
? xScale(Math.min(d.end_timestamp, domain.max)) -
Math.max(xScale(d.timestamp), startingXPos)
: 0,
ANNOTATION_MIN_WIDTH
);

const xPos = d.timestamp >= domain.min ? xScale(d.timestamp) : startingXPos;
svg
.append('rect')
.classed('mlAnnotationRect', true)
.attr('x', d.timestamp >= domain.min ? xScale(d.timestamp) : startingXPos)
// If annotation is at the end, prevent overflow by shifting it back
.attr('x', xPos + annotationWidth >= endingXPos ? endingXPos - annotationWidth : xPos)
.attr('y', 0)
.attr('height', ANNOTATION_CONTAINER_HEIGHT)
.attr('width', Math.max(annotationWidth, ANNOTATION_MIN_WIDTH))
.attr('width', annotationWidth)
.on('mouseover', function () {
const startingTime = formatHumanReadableDateTimeSeconds(d.timestamp);
const endingTime =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,6 @@ export const SwimlaneContainer: FC<SwimlaneProps> = ({
},
fontSize: 12,
},
overflow: {
rightOverflow: 50,
},
xAxisLabel: {
visible: true,
// eui color subdued
Expand Down

0 comments on commit 3151364

Please sign in to comment.