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

How to create external drawing. #53

Closed
somu2324 opened this issue Aug 28, 2019 · 1 comment
Closed

How to create external drawing. #53

somu2324 opened this issue Aug 28, 2019 · 1 comment
Assignees

Comments

@somu2324
Copy link

I am able to create graph view successfully. Now I want to add some external drawing with the graph view.
For this I want canvas context object. How can get this.

for example: In the attached image I have display two rect which is not a part of graph view but I want to display this with graph. How can I archive this.

It will be helpful for me if somehow I can get context object as a global object.

Screen Shot 2019-08-28 at 6 31 56 PM

@vasturiano vasturiano self-assigned this Sep 8, 2019
@vasturiano
Copy link
Owner

@somu2324 you can add additional drawing functionality associated with each node via .nodeCanvasObject((node, context) => ...). If you only wish to extend the node drawing and not replace it, you can set .nodeCanvasObjectMode(() => 'after').

The reason why the global context is not exposed is because the canvas is wiped and re-drawn at every frame, due to the iteration of the force layout. So, any draw operations you would do externally would immediately disappear.

Another way you could approach this is to have a separate canvas that you maintain and exactly overlaps visually with the force directed graph (using absolute positioned css). Then you can fully customize the drawing of the additional elements in your project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants