-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] Maps integration: adds influencers to tooltip in anomalies layer #126007
[ML] Maps integration: adds influencers to tooltip in anomalies layer #126007
Conversation
Pinging @elastic/ml-ui (:ml) |
Pinging @elastic/kibana-gis (Team:Geo) |
fbc3ff2
to
8373959
Compare
19a9015
to
ba81ef3
Compare
const INFLUENCER_LIMIT = 3; | ||
const INFLUENCER_MAX_VALUES = 3; | ||
|
||
function getInfluencersHtmlString( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Would be good to add some unit tests for this utility function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 1dd5976
} | ||
} | ||
|
||
return htmlString; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If influencers.length == 0, would this htmlString
be '<ul>'
which is invalid html 🤔 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call - checked for influencer length before entering the function and also moved closing tag out of the loop in 1dd5976
Pretty sure it's not related to this PR but I wasn't sure if the tooltip popups being persisted is intentional here Screen.Recording.2022-02-28.at.12.19.59.mov |
|
||
htmlString += `<li>${influencer_field_name}: ${fieldValuesString}</li>`; | ||
|
||
// Only show top two influencers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super duper nit: since INFLUENCER_LIMIT
is a constant and can potentially be changed in the future, I think this comment should not mention "two" specifically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point - removed in 1dd5976
This is expected behavior. Tooltips stay opened when clicked. Tooltips auto-hide with mouse over. https://www.elastic.co/guide/en/kibana/current/vector-tooltip.html#maps-vector-tooltip-locking |
Latest changes LGTM 🎉 |
💚 Build SucceededMetrics [docs]Async chunks
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall code LGTM. Just a general question because I don't know the consuming code: Can you explain why we need to create a raw HTML string instead of passing on React/TSX?
hi @walterra wrt #126007 (review)
It is the Maps-plugin API that requires the tooltip-value to be a html-string. The reason for that is that Kibana-field-formatted values (as defined in the Data View in Stack Management), return actual HTML-strings that need to be displayed as is. This restriction bled through to the interfaces Maps exposes and that See where this is being called and more details: Lines 341 to 350 in 9e5daa5
imho, this is an issue mainly on the MapsPlugin API-side, and needs to be resolved there first. I'd agree that the clean solution would be that external-implementers would be able to return React-dom. I'll create a follow-up ticket for Maps. |
Summary
Related meta issue: #123492
Adds influencers to the tooltip for each point on the map - if influencers are present.
Limits to 3 influencers and 3 influencer values to prevent tooltip from becoming too big.
Checklist
Delete any items that are not applicable to this PR.