vasturiano/force-graph

How can the code in ‘nodeCanvasObject()’ be written to become a node hovering style like sigma.js

FightingQueen opened this issue · 5 comments

The node is surrounded by a black background, so you can see which node the name belongs to.
At the same time, the background level is the highest and is not covered by other nodes.
How do I write the canvas code in nodeCanvasObject(node,ctx) to meet the style shown in the following picture?
I don't know much about canvas. Please give a specific code example. Thank you

example

I'm sorry, you may think the tone was stiff in the past, but I meant to ask you some questions humbly. Please don't mind

@FightingQueen thanks for reaching out.

This seems to be more a question about Canvas development rather than this module in specific. As such, you will probably get a more helpful answer by posting in StackOverflow, or a more Canvas oriented forum.

@FightingQueen thanks for reaching out.

This seems to be more a question about Canvas development rather than this module in specific. As such, you will probably get a more helpful answer by posting in StackOverflow, or a more Canvas oriented forum.

@FightingQueen thanks for reaching out.

This seems to be more a question about Canvas development rather than this module in specific. As such, you will probably get a more helpful answer by posting in StackOverflow, or a more Canvas oriented forum.

Hello, thank you very much for your reply.
I'm sorry to bother you, but I'm having a problem with the nodeCanvasObject((node,ctx)=>{}) callback function, the content drawn by ctx is covered by other nodes, as if ctx has its own level, the content drawn by ctx is the same size as the level of ctx, if the level of ctx is low, it will be covered, if the level is high, it won't be covered. If the ctx level is low, it is covered, if it is high, it is not covered, but when the mouse hovers over a node, the label that appears is always at the top and is not covered by other nodes, can you give me a solution to this?
image

Translated with www.DeepL.com/Translator (free version)

@FightingQueen you can use nodeCanvasObjectMode to specify whether you want the custom drawing to be done before, after or instead of the default node shape.

@FightingQueen you can use nodeCanvasObjectMode to specify whether you want the custom drawing to be done before, after or instead of the default node shape.

Thank you very much for your reply.
Wish you a happy life!