$("#tudiagram").ejDiagram({
width: (_mainWidth * _maxRectangles) + _widthOffset + 25, /*"1700px",*/
height: "626px",
constraints: ej.datavisualization.Diagram.DiagramConstraints.Default & ~ej.datavisualization.Diagram.DiagramConstraints.Zoomable & ~ej.datavisualization.Diagram.DiagramConstraints.Resizable,
nodes: nodes,
tooltip: null,
nodeCollectionChange: function (args) { onNodeChanged(args); },
drag: function (args) {
//console.log("drag:");
//console.log(args);
//console.log(window.mouseXPos);
//console.log("New: " + args.newValue.offsetX + " Old: " + args.oldValue.offsetX);
console.log(args.dragState);
var diag = this;
if (args.dragState == 'starting') {
dragablestartdata[args.element.name] = args.oldValue;
} else if (args.dragState == 'completed') {
setNode(args.element, args.element.name, args.newValue, diag);
} else {
var placedrows = getplacedrows(args.newValue);
var existingbundleshere = null;
if (args.element.children[0].addInfo.type == 'Divider') {
existingbundleshere = getplacedDividers(args.element.name, args.newValue);
}
else {
existingbundleshere = getplacedbundles(args.element.name, args.newValue);
}
//console.log("Moving args.element: ", args.element)
if (existingbundleshere.length == 0 && validehoveredrows(placedrows, args.element.addInfo.neededPlaceholder)) {
$.each(placedrows,
function (key, item) {
diag.updateNode(item.name, { fillColor: hoveredrowfill });
//console.log("Grid hovered");
});
}
}
var offsX = args.element.offsetX;
var width = args.element.children[0].width;
var boundaries = $('#tudiagram_canvas_svgParent')[0].getBoundingClientRect();
var rowWidth = _unit.DimensionLength * _mainWidth + _widthOffset;
if (offsX - (width / 2) < _widthOffset) {
offsX = _widthOffset + (width / 2);
}
else {
var offsXInitial = offsX - (width / 2);
/* Divider */
if (width < _mainWidth) {
//offsX = (Math.round(offsXInitial / 100) * 100) + (width / 2);
offsXInitial = window.mouseXPos - boundaries.left;
offsX = (Math.round(offsXInitial / 100) * 100) + (width / 2);
}
else {
offsX = (Math.floor(offsXInitial / 100) * 100) + (width / 2);
}
}
//console.log("offsX danach:" + offsX);
if (offsX + (width / 2) > rowWidth && offsX > 0) {
this.updateNode(args.element.name,
{
offsetX: dragablestartdata[args.element.name].offsetX,
offsetY: dragablestartdata[args.element.name].offsetY
});
return;
}
//console.log("Offset: ", offsX);
//console.log("args.element: ", args.element);
diagram.updateNode(args.element.name, { offsetX: offsX });
AllDividerToFront();
},
scrollChange: function (args) {
$("#tudiagram_canvas_svgParent").css("left", "0px");
$.each($('.remove-row-button'), function( key, value ) {
var top = value.offsetTop;
$(value).css("top", (top - (args.newValues.verticalOffset - args.oldValues.verticalOffset)) + "px");
});
},
itemClick: function(args) {
//console.log("itemClick:");
//console.log(args);
//console.log("------------------------");
},
doubleClick: function (args) { onNodeDoubleClick(args); },
snapSettings: {
enableSnapToObject: false,
horizontalGridLines: {
snapInterval: [101,152]
},
verticalGridLines: {
snapInterval: [100]
}
},
pageSettings: {
scrollLimit: "limited",
pageWidth: (_mainWidth * _maxRectangles) + _widthOffset,
pageHeight: 1500,
},
rulerSettings: {
showRulers: true,
verticalRuler: {
interval: 5,
segmentWidth: 100
},
horizontalRuler: {
segmentWidth: 100,
interval: 5
}
},
});