Permalink
Browse files

git-svn-id: https://flexapps.svn.sourceforge.net/svnroot/flexapps/cen…

…sus2@639 381d3abc-5231-0410-a0e4-b068e20cbb11
  • Loading branch information...
1 parent 1a659c6 commit 94a44f0fd4f94f873451f339aaeda7c4d0ae27cc jlward4 committed Mar 31, 2010
View
@@ -12,6 +12,8 @@
<![CDATA[
import com.jamesward.census2.utils.TextFormatters;
+ import mx.charts.BarChart;
+ import mx.charts.series.BarSeries;
import mx.controls.Alert;
import mx.core.UIComponent;
import mx.events.FlexEvent;
@@ -31,6 +33,8 @@
[Bindable]
private var chartArrayCollection:ArrayCollection = averageResultsArrayCollection;
+
+ private var selectedChartIndex:Number = -1;
private function changeTheme(theme:String):void
@@ -79,6 +83,7 @@
private function updateResult(testId:String, resultType:String, resultValue:Number):void
{
+ var i:uint = 0;
for each (var result:Object in yourResultsArrayCollection)
{
if (result.id == testId)
@@ -88,14 +93,21 @@
{
result[resultType] = resultValue;
- if (result['requestTime'] && result['totalServerTime'])
+ if ((result['requestTime'] != -1) && (result['parseTime'] != -1) && (result['renderTime'] != -1) && (result['contentLength'] != -1))
{
// calc transfer time
- updateResult(testId, "transferTime", result['requestTime'] - result['totalServerTime']);
+ //updateResult(testId, "transferTime", result['requestTime'] - result['totalServerTime']);
// assume we are done
CursorManager.removeBusyCursor();
+ // select the chart item
+ selectedChartIndex = i;
+
+ updateSelectedChartItem();
+
+ cdp.open();
+
// refresh average results
fetchAverageResults();
}
@@ -106,6 +118,8 @@
break;
}
+
+ i++;
}
}
@@ -127,15 +141,28 @@
private function switchChartArrayCollection():void
{
- cdp.close();
+ var switched:Boolean = false;
if (resultType.selection == averageResults)
{
- chartArrayCollection = averageResultsArrayCollection;
+ if (chartArrayCollection != averageResultsArrayCollection)
+ {
+ chartArrayCollection = averageResultsArrayCollection;
+ switched = true;
+ }
}
else if (resultType.selection == yourResults)
{
- chartArrayCollection = yourResultsArrayCollection;
+ if (chartArrayCollection != yourResultsArrayCollection)
+ {
+ chartArrayCollection = yourResultsArrayCollection;
+ switched = true;
+ }
+ }
+
+ if (switched)
+ {
+ cdp.close();
}
}
@@ -165,7 +192,7 @@
{
item[resultType] = event.result[resultType];
}
- item["transferTime"] = item['requestTime'] - item['totalServerTime'];
+ //item["transferTime"] = item['requestTime'] - item['totalServerTime'];
averageResultsArrayCollection.itemUpdated(item);
}
@@ -207,28 +234,55 @@
{
result.gzip = enableGZip.selected;
result.numRows = numRows.value;
- result.totalServerTime = 0;
- result.transferTime = 0;
- result.totalServerTime = 0;
- result.requestTime = 0;
- result.parseTime = 0;
- result.renderTime = 0;
- result.contentLength = 0;
- result.memorySize = 0;
+ //result.totalServerTime = 0;
+ //result.transferTime = 0;
+ //result.totalServerTime = 0;
+ result.requestTime = -1;
+ result.parseTime = -1;
+ result.renderTime = -1;
+ result.contentLength = -1;
+ result.memorySize = -1;
}
public function selectChartItem(item:Object):void
{
if (item != null)
{
- cdp.data = item.item;
+ selectedChartIndex = item.index;
cdp.open();
}
else
{
+ selectedChartIndex = -1;
+
cdp.close();
}
+
+ updateSelectedChartItem();
+ }
+
+ private function updateSelectedChartItem():void
+ {
+ if (selectedChartIndex != -1)
+ {
+ for each (var chart:BarChart in [recordsPerSecondChartView.chart, transferSizeChartView.chart, clientSideMemoryChartView.chart])
+ {
+ for each (var s:BarSeries in chart.series)
+ {
+ s.selectedIndex = selectedChartIndex;
+ }
+ }
+
+ cdp.data = chartArrayCollection.getItemAt(selectedChartIndex);
+ }
+ else
+ {
+ for each (var chart2:BarChart in [recordsPerSecondChartView.chart, transferSizeChartView.chart, clientSideMemoryChartView.chart])
+ {
+ chart2.clearSelection();
+ }
+ }
}
]]>
</mx:Script>
@@ -316,7 +370,7 @@
<mx:VBox width="100%" height="100%" horizontalAlign="center" verticalGap="0" paddingTop="40" paddingLeft="0" paddingRight="20" paddingBottom="10">
<mx:HRule width="100%"/>
<mx:Spacer height="10"/>
- <mx:VBox id="myTabs" width="100%" height="50%" verticalScrollPolicy="off" horizontalScrollPolicy="off">
+ <mx:VBox id="myTabs" width="100%" height="50%" verticalScrollPolicy="off" horizontalScrollPolicy="off" verticalGap="10">
<mx:HBox width="100%" horizontalAlign="center">
<controls:ChartLegendCombo id="clc" charts="{[recordsPerSecondChartView, transferSizeChartView, clientSideMemoryChartView]}">
<controls:change>
@@ -20,7 +20,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
click="handleArrowClick()"
horizontalScrollPolicy="off"
- width="520"
+ width="360"
+ height="26"
mouseChildren="false" useHandCursor="true" buttonMode="true"
>
@@ -89,7 +90,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
_popup.setStyle("backgroundColor", getStyle("backgroundColor"));
_popup.setStyle("borderStyle", "solid");
_popup.setStyle("borderColor", getStyle("borderColor"));
- _popup.setStyle("markerWidth", 15);
+ _popup.setStyle("markerWidth", 10);
+ _popup.setStyle("markerHeight", 10);
_popup.horizontalScrollPolicy = "off";
_popup.addEventListener(FlexMouseEvent.MOUSE_DOWN_OUTSIDE, closePopUp);
_popup.addEventListener(FlexMouseEvent.MOUSE_WHEEL_OUTSIDE, closePopUp);
@@ -212,8 +214,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<mx:Button id="b" width="100%" height="100%"/>
- <mx:HBox width="100%" horizontalGap="0" verticalAlign="middle">
- <mx:Legend id="legend" direction="horizontal" markerWidth="15" width="100%"/>
+ <mx:HBox width="100%" horizontalGap="0" verticalAlign="middle" verticalCenter="0">
+ <mx:Legend id="legend" direction="horizontal" markerWidth="10" markerHeight="10" width="100%" height="100%"/>
<mx:UIComponent id="arrow" width="20" height="20">
<mx:creationComplete>
@@ -28,41 +28,67 @@ public class TextFormatters
public static function byteFormat(labelValue:Object, previousValue:Object=null, axis:IAxis=null):String
{
var nf:NumberFormatter = new NumberFormatter();
- nf.precision = 1;
var n:Number = new Number(labelValue);
+
if (n >= 1000000)
{
+ if ((Math.floor(n / 100000) % 10) == 0)
+ {
+ nf.precision = 0;
+ }
+ else
+ {
+ nf.precision = 1;
+ }
return nf.format(n / 1000000) + " MB";
}
else if (n >= 1000)
{
+ if ((n % 10) == 0)
+ {
+ nf.precision = 0;
+ }
+ else
+ {
+ nf.precision = 1;
+ }
return nf.format(n / 1000) + " KB";
}
- else if (n == 0)
+ else if (n == -1)
{
return "n/a";
}
else
{
+ nf.precision = 0;
return nf.format(n) + " B";
}
}
public static function timeFormat(labelValue:Object, previousValue:Object=null, axis:IAxis=null):String
{
var nf:NumberFormatter = new NumberFormatter();
- nf.precision = 1;
var n:Number = new Number(labelValue);
+
if (n >= 1000)
{
+ if ((n % 10) == 0)
+ {
+ nf.precision = 0;
+ }
+ else
+ {
+ nf.precision = 1;
+ }
return nf.format(n / 1000) + " s";
}
- else if (n == 0)
+ else if (n == -1)
{
return "n/a";
}
else
{
+ nf.precision = 0;
return nf.format(n) + " ms";
}
}
@@ -77,7 +103,7 @@ public class TextFormatters
private static function getTotalTime(item:Object):Number
{
- var totalTime:Number = item.totalServerTime + item.transferTime + item.parseTime + item.renderTime;
+ var totalTime:Number = item.requestTime + item.parseTime + item.renderTime;
return totalTime;
}
@@ -91,14 +117,13 @@ public class TextFormatters
if (getTotalTime(item) > 0)
{
s += "<br/><br/><font size='14'><b>" + getRpsFormatter().format((item.numRows / (getTotalTime(item)) * 1000)) + " rows/s</b></font>" +
- "<br/><font size='12'>Server Exec Time: " + timeFormat(item.totalServerTime) + "</font>" +
- "<br/><font size='12'>Transfer Time: " + timeFormat(item.transferTime) + "</font>" +
- "<br/><font size='12'>Parse Time: " + timeFormat(item.parseTime) + "</font>" +
- "<br/><font size='12'>Render Time: " + timeFormat(item.renderTime) + "</font>" +
- "<br/><font size='12'><b>Total Time: " + timeFormat(getTotalTime(item)) + "</b></font>" +
- "<br/><br/><font size='14'><b>" + byteFormat(item.contentLength / item.numRows) + "/row</b></font>" +
- "<br/><font size='12'>Transfer Size: " + byteFormat(item.contentLength) + "</font>" +
- "<br/><br/><font size='12'>Client memory: " + byteFormat(item.memorySize) +"</font>";
+ "<br/><font size='12'>Request Time: " + timeFormat(item.requestTime) + "</font>" +
+ "<br/><font size='12'>Parse Time: " + timeFormat(item.parseTime) + "</font>" +
+ "<br/><font size='12'>Render Time: " + timeFormat(item.renderTime) + "</font>" +
+ "<br/><font size='12'><b>Total Time: " + timeFormat(getTotalTime(item)) + "</b></font>" +
+ "<br/><br/><font size='14'><b>" + byteFormat(item.contentLength / item.numRows) + "/row</b></font>" +
+ "<br/><font size='12'>Transfer Size: " + byteFormat(item.contentLength) + "</font>" +
+ "<br/><br/><font size='12'>Client memory: " + byteFormat(item.memorySize) +"</font>";
}
else
{
@@ -32,14 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<mx:SeriesInterpolate id="interpolate"/>
<mx:BarChart id="chart" width="100%" height="100%" dataProvider="{dataProvider}" verticalAxisRatio="1"
- selectionMode="single" gutterRight="20">
- <!--
- <mx:updateComplete>
- Application.application.cdp.setStyle("top", chart.computedGutters.top + 1);
- Application.application.cdp.setStyle("right", chart.computedGutters.right + 1);
- Application.application.cdp.height = chart.height - chart.computedGutters.height - 2;
- </mx:updateComplete>
- -->
+ selectionMode="multiple" gutterRight="20">
<mx:change>
var c:ChartItem = chart.selectedChartItem;
@@ -67,7 +60,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</mx:horizontalAxisRenderers>
<mx:series>
- <mx:BarSeries xField="memorySize" displayName="Client-side Memory" showDataEffect="{interpolate}" itemRenderer="com.jamesward.census2.charts.BarItemRenderer">
+ <mx:BarSeries xField="memorySize" displayName="Client-side Memory" showDataEffect="{interpolate}" itemRenderer="com.jamesward.census2.charts.BarItemRenderer"
+ selectable="true" useHandCursor="true" mouseChildren="false" buttonMode="true">
<mx:fill>
<mx:LinearGradient angle="90">
<mx:entries>
@@ -68,29 +68,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</mx:verticalAxisRenderers>
<mx:horizontalAxis>
- <mx:LinearAxis id="lrtcHA" labelFunction="TextFormatters.timeFormat"/>
+ <mx:LinearAxis id="lrtcHA" labelFunction="TextFormatters.timeFormat" minimum="0"/>
</mx:horizontalAxis>
<mx:horizontalAxisRenderers>
<charts:StyledAxisRenderer axis="{lrtcHA}"/>
</mx:horizontalAxisRenderers>
<mx:series>
- <mx:BarSeries id="totalServerTimeSeries" xField="totalServerTime" showDataEffect="{interpolate}" displayName="Server Exec Time" itemRenderer="com.jamesward.census2.charts.BarItemRenderer"
+ <mx:BarSeries xField="requestTime" showDataEffect="{interpolate}" displayName="Request Time" itemRenderer="com.jamesward.census2.charts.BarItemRenderer"
selectable="true" useHandCursor="true" mouseChildren="false" buttonMode="true">
- <mx:fill>
- <mx:LinearGradient angle="90">
- <mx:entries>
- <mx:Array>
- <mx:GradientEntry color="#e28741" ratio="0" alpha="100"/>
- <mx:GradientEntry color="#c6691c" ratio="1" alpha="100"/>
- </mx:Array>
- </mx:entries>
- </mx:LinearGradient>
- </mx:fill>
- </mx:BarSeries>
- <mx:BarSeries xField="transferTime" showDataEffect="{interpolate}" displayName="Transfer Time" itemRenderer="com.jamesward.census2.charts.BarItemRenderer"
- selectable="true" useHandCursor="true" mouseChildren="false" buttonMode="true" currentState="{totalServerTimeSeries.currentState}">
<mx:fill>
<mx:LinearGradient angle="90">
<mx:entries>
@@ -103,7 +90,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</mx:fill>
</mx:BarSeries>
<mx:BarSeries xField="parseTime" showDataEffect="{interpolate}" displayName="Parse Time" itemRenderer="com.jamesward.census2.charts.BarItemRenderer"
- selectable="true" useHandCursor="true" mouseChildren="false" buttonMode="true" currentState="{totalServerTimeSeries.currentState}">
+ selectable="true" useHandCursor="true" mouseChildren="false" buttonMode="true">
<mx:fill>
<mx:LinearGradient angle="90">
<mx:entries>
@@ -116,7 +103,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</mx:fill>
</mx:BarSeries>
<mx:BarSeries xField="renderTime" showDataEffect="{interpolate}" displayName="Render Time" itemRenderer="com.jamesward.census2.charts.BarItemRenderer"
- selectable="true" useHandCursor="true" mouseChildren="false" buttonMode="true" currentState="{totalServerTimeSeries.currentState}">
+ selectable="true" useHandCursor="true" mouseChildren="false" buttonMode="true">
<mx:fill>
<mx:LinearGradient angle="90">
<mx:entries>
Oops, something went wrong.

0 comments on commit 94a44f0

Please sign in to comment.