-
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
[APM] Service Map Layout #59020
[APM] Service Map Layout #59020
Conversation
First of all, this looks amazing @ogupte 🎉 Much better-looking layout for the maps. I've got a few comments and questions;
I would love to see this with another dataset to see how it will display the nodes etc. |
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.
Apart from my comments, I think this is a definite improvement over the existing map layout.
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.
) | ||
.addParameters({ | ||
options: { | ||
// theme: create({ |
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.
Remove these comments?
} | ||
]; | ||
|
||
export const cytoscapeOptions: cytoscape.CytoscapeOptions = { | ||
autoungrabify: true, | ||
boxSelectionEnabled: false, | ||
layout, | ||
// layout, |
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.
Remove this comment?
@@ -75,7 +71,10 @@ const style: cytoscape.Stylesheet[] = [ | |||
{ | |||
selector: 'edge', | |||
style: { | |||
'curve-style': 'bezier', | |||
// 'curve-style': 'bezier', |
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.
Remove this comment
cy.removeListener('mouseover', 'edge, node', mouseoverHandler); | ||
cy.removeListener('mouseout', 'edge, node', mouseoutHandler); | ||
} | ||
}; | ||
}, [cy, serviceName]); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps |
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.
Why are we disabling exhaustive deps here?
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.
i was able to rearrange the code to safely remove this
animationEasing: animationOptions.easing, | ||
animationDuration: animationOptions.duration, | ||
// Rotate nodes from top -> bottom to display left -> right | ||
// @ts-ignore |
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.
You can put a description of why we're ignoring something after the @ts-ignore
on the same line comment.
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.
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.
@sqren I'll just wait until this is merged and open a PR that updates the types and removes the comments that can be removed.
// Set up cytoscape event handlers | ||
useEffect(() => { | ||
const dataHandler: cytoscape.EventHandler = event => { | ||
const dataHandler = useCallback( |
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.
The typing of this with the extra argument is weird now, so I think maybe there should be two functions, one that actually is an EventHandler
(that you can type with useCallback<cytoscape.EventHandler>
and the one that takes the extra argument that gets wrapped.
It's not a big thing, but I'd rather have more verbose code than confusing types.
function isService(el: cytoscape.NodeSingular) { | ||
return el.data('type') === 'service'; | ||
} | ||
|
||
const style: cytoscape.Stylesheet[] = [ | ||
// @ts-ignore |
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 we update to the latest @types/cytoscape
some of these will go away. We should. I know visibility
is in there as of the latest.
@@ -75,7 +71,10 @@ const style: cytoscape.Stylesheet[] = [ | |||
{ | |||
selector: 'edge', | |||
style: { | |||
'curve-style': 'bezier', | |||
// 'curve-style': 'bezier', |
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.
Remove comment.
@@ -8,13 +8,17 @@ import { useWindowSize } from 'react-use'; | |||
|
|||
export function useRefHeight(): [ |
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.
This probably should be renamed to something like useRefDimensions
since it gets height and width now.
|
||
const height = ref.current ? windowHeight - topOffset : 0; | ||
|
||
return [ref, height]; | ||
return [ref, height, width]; | ||
} |
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.
A quick scan: looks like it would be more clear to return the default value early and the conditionals disappear (untested):
export function useRefHeight(): [
MutableRefObject<HTMLDivElement | null>,
number,
number
] {
const ref = useRef<HTMLDivElement>(null);
if (!ref.current) {
return [ref, 0, 0];
}
const windowHeight = useWindowSize().height;
const { top, width } = ref.current.getBoundingClientRect();
const height = windowHeight - top;
return [ref, height, width];
}
Btw what do you think about returning an object similar to how useWindowSize
works?
return { ref, height, width };
- uses the core breadthfirst cytoscape layout - rotates elements by -90degrees - selects rum nodes as roots - implements hover styles to show connected nodes - fixes flash of unstyled cytoscape elements on initial load
56153da
to
e8d955e
Compare
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* Addresses elastic#55544. - uses the core breadthfirst cytoscape layout - rotates elements by -90degrees - selects rum nodes as roots - implements hover styles to show connected nodes - fixes flash of unstyled cytoscape elements on initial load * PR review feedback * adds canned response for testing cytoscape layout in storybook * update dep snapshot for removing cytoscape-dagre
* Addresses #55544. - uses the core breadthfirst cytoscape layout - rotates elements by -90degrees - selects rum nodes as roots - implements hover styles to show connected nodes - fixes flash of unstyled cytoscape elements on initial load * PR review feedback * adds canned response for testing cytoscape layout in storybook * update dep snapshot for removing cytoscape-dagre
Addresses #55544: