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

Please add an incoming parameter for custom shape node #2168

Open
joylix opened this issue Jul 1, 2024 · 0 comments
Open

Please add an incoming parameter for custom shape node #2168

joylix opened this issue Jul 1, 2024 · 0 comments

Comments

@joylix
Copy link

joylix commented Jul 1, 2024

In custom shape node, in order to dynamically pass the color and border color of the node into ctxRenderer method, so that the display properties of the node can be dynamically changed, I did not find suitable input parameters and could only use a custom string segmentation method:

{ id: 3,
  label: "node3 | blue | yellow | caption",     
  shape: "custom",
  ctxRenderer: ({
    ctx, id,	x, y,	state: { selected, hover },	style, label,			
 }) => {				
    const drawNode = () => {
    ctx.beginPath();
    ...
    ctx.closePath();
    ctx.save();      
    ctx.fillStyle = label.split("|")[1];         //background:blue
    ctx.fill();
    ctx.strokeStyle =  label.split("|")[2];      //border:yellow
    ctx.fillText( label.split("|")[3], x,y);         //caption:caption
   }

I can't find any better way to achieve this .

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

1 participant