@@ -93624,7 +93624,6 @@ azdataQueryPlan.prototype.renderPolygons = function () {
9362493624azdataQueryPlan.prototype.getPolygonPerimeter = function (cell) {
9362593625 let points = [];
9362693626 points = points.concat(this.getLeftSidePoints(cell));
93627-
9362893627 let rightSidePoints = this.getRightSidePoints(cell);
9362993628 points = points.concat(this.getBottomSidePoints(cell, rightSidePoints[0].x));
9363093629 points = points.concat(rightSidePoints);
@@ -93642,9 +93641,13 @@ const NODE_WIDTH = 100;
9364293641 */
9364393642azdataQueryPlan.prototype.getLeftSidePoints = function (cell) {
9364493643 let points = [];
93644+
93645+ // let additionalLeftSideSpacing = longestSubLabel % 10 * 25;
93646+ let additionalLeftSideSpacing = this.calcAdditionalSpacingForNode(cell);
93647+
9364593648 let xPosition = cell.geometry.x - 15; // subtracting to push the x coordinate to the left.
93646- points.push({ x: xPosition, y: cell.geometry.y });
93647- points.push({ x: xPosition, y: cell.geometry.y + NODE_HEIGHT });
93649+ points.push({ x: xPosition - additionalLeftSideSpacing , y: cell.geometry.y });
93650+ points.push({ x: xPosition - additionalLeftSideSpacing , y: cell.geometry.y + NODE_HEIGHT });
9364893651
9364993652 return points;
9365093653}
@@ -93656,64 +93659,51 @@ azdataQueryPlan.prototype.getLeftSidePoints = function (cell) {
9365693659 */
9365793660azdataQueryPlan.prototype.getBottomSidePoints = function (cell, polygonRightSideConstraint) {
9365893661 let points = [];
93659- let bottomSideLeafNodes = this.getBottomSideLeafNodes (cell, polygonRightSideConstraint);
93662+ let bottomSideNodes = this.getBottomSideNodes (cell, polygonRightSideConstraint);
9366093663
93661- for (let index = 0; index < bottomSideLeafNodes.length; ++index) {
93662- let leafNode = bottomSideLeafNodes[index].value;
93663- let leftOfLeafNode = leafNode;
93664+ bottomSideNodes.forEach(node => {
93665+ let lastPoint = points.length > 0 ? points[points.length - 1] : null;
9366493666
93665- // Finds the left most node directly to the left of the leaf node.
93666- while (leftOfLeafNode.position.y === leftOfLeafNode.parent.position.y) {
93667- leftOfLeafNode = leftOfLeafNode.parent;
93668- }
93667+ let newPoint = { x: node.geometry.x, y: node.geometry.y + NODE_HEIGHT };
9366993668
93670- if (points.length === 0) {
93671- let parent = leftOfLeafNode.parent;
93672- let auxiliaryPoint = { x: leftOfLeafNode.position.x - NODE_WIDTH, y: parent.position.y + NODE_HEIGHT };
93673- points.push(auxiliaryPoint);
93674- }
93675- else if (points.length !== 0 && points[points.length - 1].y - NODE_HEIGHT !== leftOfLeafNode.position.y) {
93676- let auxiliaryPoint = { x: leftOfLeafNode.position.x - NODE_WIDTH, y: points[points.length - 1].y };
93669+ if (lastPoint && newPoint.y !== lastPoint.y) {
93670+ let auxiliaryPoint = { x: lastPoint.x, y: newPoint.y };
9367793671 points.push(auxiliaryPoint);
9367893672 }
9367993673
93680- points.push({ x: leftOfLeafNode.position.x - NODE_WIDTH, y: leftOfLeafNode.position.y + NODE_HEIGHT });
93674+ let cell = this.graph.model.getCell(node.id);
93675+ let additionalSpacing = Math.max(...(cell.value.label.split(/\r\n|\n/).map(str => str.length))) > 20 ? this.calcAdditionalSpacingForNode(cell) : 0;
9368193676
93682- if (leftOfLeafNode.position.x < leafNode.position.x) {
93683- points.push({ x: leafNode.position.x + NODE_WIDTH, y: leafNode.position.y + NODE_HEIGHT});
93684- }
93685- }
93677+ points.push({ x: node.geometry.x, y: node.geometry.y + NODE_HEIGHT });
93678+ points.push({ x: node.geometry.x + NODE_WIDTH + additionalSpacing, y: node.geometry.y + NODE_HEIGHT });
93679+ });
9368693680
9368793681 return points;
9368893682}
9368993683
93690- azdataQueryPlan.prototype.getBottomSideLeafNodes = function (cell, polygonRightSideConstraint) {
93691- let leafNodeTable = {} ;
93692- let stack = [cell ];
93684+ azdataQueryPlan.prototype.getBottomSideNodes = function (cell, polygonRightSideConstraint) {
93685+ let queue = [cell] ;
93686+ let nodes = [];
9369393687
93694- while (stack .length !== 0) {
93695- let entry = stack.pop() ;
93688+ while (queue .length !== 0) {
93689+ let levelNodeCount = queue.length ;
9369693690
93697- if (entry.value.children.length === 0 && entry.geometry.x <= polygonRightSideConstraint) {
93698- if (entry.geometry.x in leafNodeTable) {
93699- let previouslyCachedEntry = leafNodeTable[entry.geometry.x];
93700- if (entry.geometry.y > previouslyCachedEntry.geometry.y) {
93701- leafNodeTable[entry.geometry.x] = entry;
93702- }
93703- }
93704- else {
93705- leafNodeTable[entry.geometry.x] = entry;
93691+ for (let nodeIndex = 0; nodeIndex < levelNodeCount; ++nodeIndex) {
93692+ let entry = queue.shift();
93693+
93694+ if (nodeIndex === levelNodeCount - 1 && entry.geometry.x < polygonRightSideConstraint) {
93695+ nodes.push(entry)
9370693696 }
93707- }
9370893697
93709- for (let nodeIndex = 0; nodeIndex < entry.value.children.length; ++nodeIndex) {
93710- stack.push(this.graph.model.getCell(entry.value.children[nodeIndex].id));
93698+ for (let childIndex = 0; childIndex < entry.value.children.length; ++childIndex) {
93699+ if (entry.geometry.x < polygonRightSideConstraint) {
93700+ queue.push(this.graph.model.getCell(entry.value.children[childIndex].id));
93701+ }
93702+ }
9371193703 }
9371293704 }
9371393705
93714- let leafNodes = Object.keys(leafNodeTable).map(key => leafNodeTable[key])
93715-
93716- return leafNodes;
93706+ return nodes;
9371793707}
9371893708
9371993709/**
@@ -93723,22 +93713,26 @@ azdataQueryPlan.prototype.getBottomSideLeafNodes = function (cell, polygonRightS
9372393713 */
9372493714azdataQueryPlan.prototype.getRightSidePoints = function (cell) {
9372593715 let points = [];
93726- let leafNodes = this.getLeafNodes(cell);
93716+ let leafs = this.getLeafNodes(cell);
9372793717
93728- for (let nodeIndex = 0; nodeIndex < leafNodes .length; ++nodeIndex ) {
93729- let leafNode = leafNodes[nodeIndex ];
93718+ for (let leafIndex = 0; leafIndex < leafs .length; ++leafIndex ) {
93719+ let leaf = leafs[leafIndex ];
9373093720
93731- let longestSubLabel = Math.max(...(leafNode.value.label.split(/\r\n|\n/).map(str => str.length)));
93732- // These values to work best for drawing regions around labels of different lengths, so the label is always inside the polygon.
93733- let additionalRightSideSpacing = longestSubLabel % 10 * 25;
93721+ let additionalRightSideSpacing = this.calcAdditionalSpacingForNode(leaf);
9373493722
93735- points.push({ x: leafNode .geometry.x + NODE_WIDTH + additionalRightSideSpacing, y: leafNode .geometry.y + NODE_HEIGHT });
93736- points.push({ x: leafNode .geometry.x + NODE_WIDTH + additionalRightSideSpacing, y: leafNode .geometry.y });
93723+ points.push({ x: leaf .geometry.x + NODE_WIDTH + additionalRightSideSpacing, y: leaf .geometry.y + NODE_HEIGHT });
93724+ points.push({ x: leaf .geometry.x + NODE_WIDTH + additionalRightSideSpacing, y: leaf .geometry.y });
9373793725 }
9373893726
9373993727 return points;
9374093728}
9374193729
93730+ azdataQueryPlan.prototype.calcAdditionalSpacingForNode = function(cell) {
93731+ let longestSubLabel = Math.max(...(cell.value.label.split(/\r\n|\n/).map(str => str.length)));
93732+ // These values to work best for drawing regions around labels of different lengths, so the label is always inside the polygon.
93733+ return longestSubLabel / 10 * 15;
93734+ }
93735+
9374293736/**
9374393737 * Helper function to get the right most nodes of the polygon in a execution plan
9374493738 * @param {*} cell The root node that will be used to find all of the leaf nodes
0 commit comments