I am new to zoom charts (net charts) and I have a couple of questions:
- I would like to be able to drag a node and when the user drops it, to process the event. Is there a way to do that? I was looking at the onPositionChange event, but that event fires multiple times during the drag. There is no way to know when the user actually dropped the node. At least I did not find a way to determine that. Maybe I am missing something.
- I have a list of items that I want to be able to drag into the chart and convert them into Nodes. This works fine except that when I consume the dragend (of the external item) event I cannot properly set the x and y positioning of the newly created Node. I tried using ClientX and ClientY, LayerX and LayerY, and the other coordinates provided by the DragEnd event args, but none of them positions the Node where the cursor was released. What is the best way to accomplish this?
Here is my chart definition:
this.chart = new ZoomCharts.NetChart({
container: chartContainer,
area: {
height: null,
style: { fillColor: "rgba(14,33,40,0.9)" }
},
data: {
preloaded: {
"nodes": this.nodes,
"links": this.links
}
},
events: {
onRightClick: function (event: any, args: any) {
//set up the customer context menu
event.preventDefault();
},
onHoverChange: function (event: any, args: any) {
var content = "";
if (args.hoverNode) {
content = args.hoverNode.data.description;
}
infoElementVisible = !!content;
infoElement.innerHTML = content;
//delay the showing
if (infoElementVisible) {
setTimeout(() => {
infoElement.style.display = infoElementVisible ? "block" : "none";
}, 1000);
} else {
infoElement.style.display = infoElementVisible ? "block" : "none";
}
}
},
style: {
nodeStyleFunction: function (node: any) {
if (node.selected) {
node.lineColor = "yellow";
node.lineWidth = 3;
node.radius = node.radius * 1.5;
} else {
node.lineColor = null;
node.lineWidth = 0;
}
node.userLock = true;
node.label = node.data.name;
if (node.data.auras == "Selection GNQ") {
node.fillColor = "darkorange";
} else {
node.fillColor = "cyan";
}
},
linkStyleFunction: function (link: any) {
link.fromDecoration = "circle";
link.toDecoration = "arrow";
link.radius = 5;
},
node: {
radius: 50,
imageCropping: true,
shadowBlur: 15,
shadowColor: "#262626",
fillColor: "rgba(44,233,233,0.8)"
},
nodeHovered: {
shadowColor: "white",
shadowBlur: 15,
},
nodeLabelScaleBase: 25,
nodeSelected: {
lineColor: null
},
selection: {
fillColor: null,
lineColor: null
},
nodeFocused: {
shadowColor: "yellow",
shadowBlur: 15
},
nodeLabel: {
textStyle: { font: '24px Arial' }
}
},
theme: ZoomCharts.NetChart.themes.dark,
layout: {
mode: 'static',
nodeSpacing: 100
}
});
Thank you.