Skip to content
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

[ML] Fix Single Metric Viewer annotation tooltip hard to trigger #98233

Merged
merged 9 commits into from
Apr 29, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ export const AnnotationFlyout: FC<any> = (props) => {
size="m"
aria-labelledby="Add annotation"
data-test-subj={'mlAnnotationFlyout'}
className={'mlAnnotationFlyout'}
>
<EuiFlyoutHeader hasBorder>
<EuiTitle size="s">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ $mlAnnotationRectDefaultFillOpacity: .05;

fill: $euiColorFullShade;
transition: fill $euiAnimSpeedFast;

user-select: none;

}

.mlAnnotationText-isBlur {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,19 @@ export function renderAnnotations(
const levelHeight = ANNOTATION_LEVEL_HEIGHT;
const levels = getAnnotationLevels(focusAnnotationData);

const onAnnotationMouseOver = function (this: object, d: Annotation) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any type of 'mouseover' cotext (this) available?

showFocusChartTooltip(d, this);
};

const onAnnotationClick = (d: Annotation) => {
// clear a possible existing annotation previously set for editing before setting the new one.
// this needs to be done explicitly here because a new annotation created using the brush tool
// could still be present in the chart.
annotationUpdatesService.setValue(null);
// set the actual annotation and trigger the flyout
annotationUpdatesService.setValue(d);
darnautov marked this conversation as resolved.
Show resolved Hide resolved
};

const annotations = focusChart
.select('.mlAnnotations')
.selectAll('g.mlAnnotation')
Expand All @@ -148,18 +161,9 @@ export function renderAnnotations(
.attr('ry', ANNOTATION_RECT_BORDER_RADIUS)
.classed('mlAnnotationRect', true)
.attr('mask', `url(#${ANNOTATION_MASK_ID})`)
.on('mouseover', function (this: object, d: Annotation) {
showFocusChartTooltip(d, this);
})
.on('mouseout', () => hideFocusChartTooltip())
.on('click', (d: Annotation) => {
// clear a possible existing annotation set up for editing before setting the new one.
// this needs to be done explicitly here because a new annotation created using the brush tool
// could still be present in the chart.
annotationUpdatesService.setValue(null);
// set the actual annotation and trigger the flyout
annotationUpdatesService.setValue(d);
});
.on('mouseover', onAnnotationMouseOver)
.on('mouseout', hideFocusChartTooltip)
.on('click', onAnnotationClick);

rects
.attr('x', (d: Annotation) => {
Expand Down Expand Up @@ -196,9 +200,18 @@ export function renderAnnotations(
.attr('width', ANNOTATION_TEXT_RECT_WIDTH)
.attr('height', ANNOTATION_TEXT_RECT_HEIGHT)
.attr('rx', ANNOTATION_RECT_BORDER_RADIUS)
.attr('ry', ANNOTATION_RECT_BORDER_RADIUS);
.attr('ry', ANNOTATION_RECT_BORDER_RADIUS)
.on('mouseover', onAnnotationMouseOver)
.on('mouseout', hideFocusChartTooltip)
.on('click', onAnnotationClick);

texts.enter().append('text').classed('mlAnnotationText', true);
texts
.enter()
.append('text')
.classed('mlAnnotationText', true)
.on('mouseover', onAnnotationMouseOver)
.on('mouseout', hideFocusChartTooltip)
.on('click', onAnnotationClick);

function labelXOffset(ts: number) {
const earliestMs = focusXScale.domain()[0];
Expand Down