// This is just the normal way to add a circle... var circle = new Konva.Circle({ x: gStage.getWidth() / 2, y: gStage.getHeight() / 2, radius: 70, fill: 'red', stroke: 'black', strokeWidth: 4, preventDefault: true }); gLayer.add(circle); // Now get and set my data specific to my app. circle.setAttr('something', 'yes'); // <--- var something = circle.getAttr('something'); // <---There's also setAttrs() getAttrs() for setting/getting a bunch at once. More info https://konvajs.github.io/api/Konva.Node.html
Programming Tips - Konva: keep some of my own data in a Konva shape
Date: 2018apr5
Library: Konva
Language: javaScript
Q. Konva: keep some of my own data in a Konva shape
A. Use setAttr() and getAttr() like this: