瀏覽代碼

Impact analysis cosmetics:
- remove empty groups, since it may happen
- properly scale the borders of groups and redundancy groups
- automatically rescale the graph when showing/hiding the "Filter" tab

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3715 a333f486-631f-4898-b8df-5754b55c2be0

dflaven 9 年之前
父節點
當前提交
56f7657e7e
共有 3 個文件被更改,包括 44 次插入9 次删除
  1. 1 1
      application/displayblock.class.inc.php
  2. 14 6
      core/displayablegraph.class.inc.php
  3. 29 2
      js/simple_graph.js

+ 1 - 1
application/displayblock.class.inc.php

@@ -857,7 +857,7 @@ class DisplayBlock
 				$oPage->add_ready_script(
 <<<EOF
 		$("#dh_$sId").click( function() {
-			$("#ds_$sId").slideToggle('normal', function() { $("#ds_$sId").parent().resize(); FixSearchFormsDisposition(); } );
+			$("#ds_$sId").slideToggle('normal', function() { $("#ds_$sId").parent().resize(); FixSearchFormsDisposition();  $("#dh_$sId").trigger('toggle_complete'); } );
 			$("#dh_$sId").toggleClass('open');
 		});
 EOF

+ 14 - 6
core/displayablegraph.class.inc.php

@@ -446,7 +446,7 @@ class DisplayableRedundancyNode extends DisplayableNode
 		$aNode['id'] = $this->GetId();	
 		$fDiscOpacity = ($this->GetProperty('is_reached') ? 1 : 0.2);
 		$sColor = ($this->GetProperty('is_reached_count') > $this->GetProperty('threshold')) ? '#c33' : '#999';
-		$aNode['disc_attr'] = array('stroke-width' => 3, 'stroke' => '#000', 'fill' => $sColor, 'opacity' => $fDiscOpacity);
+		$aNode['disc_attr'] = array('stroke-width' => 2, 'stroke' => '#000', 'fill' => $sColor, 'opacity' => $fDiscOpacity);
 		$fTextOpacity = ($this->GetProperty('is_reached') ? 1 : 0.4);
 		$aNode['text_attr'] = array('fill' => '#fff', 'opacity' => $fTextOpacity);
 		$aNode['tooltip'] = $this->GetTooltip($aContextDefs);
@@ -662,7 +662,7 @@ class DisplayableGroupNode extends DisplayableNode
 		$fDiscOpacity = ($this->GetProperty('is_reached') ? 1 : 0.2);
 		$fTextOpacity = ($this->GetProperty('is_reached') ? 1 : 0.4);
 		$aNode['icon_attr'] = array('opacity' => $fTextOpacity);
-		$aNode['disc_attr'] = array('stroke-width' => 3, 'stroke' => '#000', 'fill' => '#fff', 'opacity' => $fDiscOpacity);
+		$aNode['disc_attr'] = array('stroke-width' => 2, 'stroke' => '#000', 'fill' => '#fff', 'opacity' => $fDiscOpacity);
 		$aNode['text_attr'] = array('fill' => '#000', 'opacity' => $fTextOpacity);
 		$aNode['tooltip'] = $this->GetTooltip($aContextDefs);
 		return $aNode;
@@ -876,9 +876,17 @@ class DisplayableGraph extends SimpleGraph
 			set_time_limit($iLoopTimeLimit);
 			if ($oNode instanceof DisplayableGroupNode)
 			{
-				$aGroups[] = $oNode->GetObjects();
-				$oNode->SetProperty('group_index', $iGroupIdx);
-				$iGroupIdx++;
+				if ($oNode->GetObjectCount() == 0)
+				{
+					// Remove emtpry groups
+					$oNewGraph->_RemoveNode($oNode);
+				}
+				else
+				{
+					$aGroups[] = $oNode->GetObjects();
+					$oNode->SetProperty('group_index', $iGroupIdx);
+					$iGroupIdx++;
+				}
 			}
 		}
 		
@@ -1279,7 +1287,7 @@ class DisplayableGraph extends SimpleGraph
 <<<EOF
 	$( "#tabbedContent_0" ).tabs({ heightStyle: "fill" });
 	$("#dh_flash").click( function() {
-		$("#ds_flash").slideToggle('normal', function() { $("#ds_flash").parent().resize(); } );
+		$("#ds_flash").slideToggle('normal', function() { $("#ds_flash").parent().resize(); $("#dh_flash").trigger('toggle_complete'); } );
 		$("#dh_flash").toggleClass('open');
 	});
     $('#ReloadMovieBtn').button().button('disable');

+ 29 - 2
js/simple_graph.js

@@ -84,6 +84,7 @@ $(function()
 				});					
 			}
 			$(window).bind('resized', function() { var that = me; window.setTimeout(function() { that._on_resize(); }, 50); } );
+			$('#dh_flash').bind('toggle_complete', function() { var that = me; window.setTimeout(function() { that._on_resize(); }, 50); } );
 			this.element.bind('mousewheel', function(event, delta, deltaX, deltaY) {
 			    return me._on_mousewheel(event, delta, deltaX, deltaY);
 			});
@@ -158,7 +159,20 @@ $(function()
 			switch(oNode.shape)
 			{
 				case 'disc':
-				oNode.aElements.push(this.oPaper.circle(xPos, yPos, iWidth*fTotalZoom / 2).attr(oNode.disc_attr));
+				oScaledAttr = {};
+				for(k in oNode.disc_attr)
+				{
+					value = oNode.disc_attr[k]
+					switch(k)
+					{
+						// Scalable attributes
+						case 'stroke-width':
+						value = value * fTotalZoom;
+						break;
+					}
+					oScaledAttr[k] = value;
+				}
+				oNode.aElements.push(this.oPaper.circle(xPos, yPos, iWidth*fTotalZoom / 2).attr(oScaledAttr));
 				var oText = this.oPaper.text(xPos, yPos, oNode.label);
 				oNode.text_attr['font-size'] = iFontSize * fTotalZoom;
 				oText.attr(oNode.text_attr);
@@ -168,7 +182,20 @@ $(function()
 					
 				case 'group':
 				oNode.aElements.push(this.oPaper.circle(xPos, yPos, iWidth*fTotalZoom / 2).attr({fill: '#fff', 'stroke-width':0}));
-				oNode.aElements.push(this.oPaper.circle(xPos, yPos, iWidth*fTotalZoom / 2).attr(oNode.disc_attr));
+				oScaledAttr = {};
+				for(k in oNode.disc_attr)
+				{
+					value = oNode.disc_attr[k]
+					switch(k)
+					{
+						// Scalable attributes
+						case 'stroke-width':
+						value = value * fTotalZoom;
+						break;
+					}
+					oScaledAttr[k] = value;
+				}
+				oNode.aElements.push(this.oPaper.circle(xPos, yPos, iWidth*fTotalZoom / 2).attr(oScaledAttr));
 				var xIcon = xPos - 18 * fTotalZoom;
 				var yIcon = yPos - 18 * fTotalZoom;
 				oNode.aElements.push(this.oPaper.image(oNode.icon_url, xIcon, yIcon, 16*fTotalZoom, 16*fTotalZoom).attr(oNode.icon_attr));