flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject git commit: [flex-asjs] [refs/heads/develop] - Updated FlexJS charts to display data more accurately by introducing minimum and maximum values to the axis beads. The charts now scale according to the values of the axis beads.
Date Mon, 08 Dec 2014 20:46:22 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop f1b2afbe9 -> 414100493


Updated FlexJS charts to display data more accurately by introducing minimum and maximum values
to the axis beads. The charts now scale according to the values of the axis beads.


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/41410049
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/41410049
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/41410049

Branch: refs/heads/develop
Commit: 414100493052a76fed287afda6910bfbe7133da7
Parents: f1b2afb
Author: Peter Ent <pent@apache.org>
Authored: Mon Dec 8 15:46:18 2014 -0500
Committer: Peter Ent <pent@apache.org>
Committed: Mon Dec 8 15:46:18 2014 -0500

----------------------------------------------------------------------
 .../charts/beads/HorizontalCategoryAxisBead.as  | 16 +++++
 .../charts/beads/HorizontalLinearAxisBead.as    | 38 ++++++-----
 .../charts/beads/VerticalCategoryAxisBead.as    | 16 +++++
 .../flex/charts/beads/VerticalLinearAxisBead.as | 43 +++++++------
 .../flex/charts/beads/layouts/BarChartLayout.as | 28 ++++++---
 .../charts/beads/layouts/ColumnChartLayout.as   | 31 ++++++---
 .../layouts/LineChartCategoryVsLinearLayout.as  | 31 ++++++---
 .../layouts/LineChartLinearVsLinearLayout.as    | 66 +++++++++++++-------
 .../beads/layouts/StackedBarChartLayout.as      | 26 +++++---
 .../beads/layouts/StackedColumnChartLayout.as   | 27 +++++---
 .../flex/charts/core/IHorizontalAxisBead.as     | 22 +++++++
 .../flex/charts/core/IVerticalAxisBead.as       | 22 +++++++
 12 files changed, 266 insertions(+), 100 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/41410049/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/HorizontalCategoryAxisBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/HorizontalCategoryAxisBead.as
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/HorizontalCategoryAxisBead.as
index b65d7ac..3d54bd4 100644
--- a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/HorizontalCategoryAxisBead.as
+++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/HorizontalCategoryAxisBead.as
@@ -116,6 +116,22 @@ package org.apache.flex.charts.beads
 		}
 		
 		/**
+		 * @private
+		 */
+		public function get maximum():Number
+		{
+			return Number.NaN;
+		}
+		
+		/**
+		 * @private
+		 */
+		public function get minimum():Number
+		{
+			return 0;
+		}
+		
+		/**
 		 *  @copy org.apache.flex.core.IBead#strand
 		 *  
 		 *  @langversion 3.0

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/41410049/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/HorizontalLinearAxisBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/HorizontalLinearAxisBead.as
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/HorizontalLinearAxisBead.as
index 41a0666..ddc6174 100644
--- a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/HorizontalLinearAxisBead.as
+++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/HorizontalLinearAxisBead.as
@@ -77,7 +77,7 @@ package org.apache.flex.charts.beads
 		
 		/**
 		 *  The name of field within the chart data the holds the value being mapped
-		 *  to this axis. If values should fall within minValue and maxValue but if
+		 *  to this axis. If values should fall within minimum and maximum but if
 		 *  not, they will be fixed to the closest value.
 		 *
 		 *  @langversion 3.0
@@ -94,10 +94,10 @@ package org.apache.flex.charts.beads
 			_valueField = value;
 		}
 		
-		private var _minValue:Number = Number.NaN;
+		private var _minimum:Number = 0;
 		
 		/**
-		 *  The minimun value to be represented on this axis. If minValue is NaN,
+		 *  The minimun value to be represented on this axis. If minimum is NaN,
 		 *  the value is calculated from the data.
 		 *
 		 *  @langversion 3.0
@@ -105,19 +105,19 @@ package org.apache.flex.charts.beads
 		 *  @playerversion AIR 2.6
 		 *  @productversion FlexJS 0.0
 		 */
-		public function get minValue():Number
+		public function get minimum():Number
 		{
-			return _minValue;
+			return _minimum;
 		}
-		public function set minValue(value:Number):void
+		public function set minimum(value:Number):void
 		{
-			_minValue = value;
+			_minimum = value;
 		}
 		
-		private var _maxValue:Number = Number.NaN;
+		private var _maximum:Number = Number.NaN;
 		
 		/**
-		 *  The maximum value to be represented on this axis. If maxValue is NaN,
+		 *  The maximum value to be represented on this axis. If maximum is NaN,
 		 *  the value is calculated from the data.
 		 *
 		 *  @langversion 3.0
@@ -125,13 +125,13 @@ package org.apache.flex.charts.beads
 		 *  @playerversion AIR 2.6
 		 *  @productversion FlexJS 0.0
 		 */
-		public function get maxValue():Number
+		public function get maximum():Number
 		{
-			return _maxValue;
+			return _maximum;
 		}
-		public function set maxValue(value:Number):void
+		public function set maximum(value:Number):void
 		{
-			_maxValue = value;
+			_maximum = value;
 		}
 		
 		/**
@@ -186,23 +186,27 @@ package org.apache.flex.charts.beads
 			var xpos:Number = 0;
 			var useWidth:Number = UIBase(axisGroup).width;
 			var series:Array = IChart(strand).series;
+			var maxValue:Number = Number.MIN_VALUE;
+			var minValue:Number = Number.MAX_VALUE;
 			
 			// determine minimum and maximum values, if needed
-			if (isNaN(minValue)) {
-				minValue = Number.MAX_VALUE;
+			if (isNaN(minimum)) {
 				for(var i:int=0; i < items.length; i++) {
 					var value:Number = Number(items[i][valueField]);
 					if (!isNaN(value)) minValue = Math.min(minValue,value);
 					else minValue = Math.min(minValue,0);
 				}
+			} else {
+				minValue = minimum;
 			}
-			if (isNaN(maxValue)) {
-				maxValue = Number.MIN_VALUE;
+			if (isNaN(maximum)) {
 				for(i=0; i < items.length; i++) {
 					value = Number(items[i][valueField]);
 					if (!isNaN(value)) maxValue = Math.max(maxValue,value);
 					else maxValue = Math.max(maxValue,0);
 				}
+			} else {
+				maxValue = maximum;
 			}
 			
 			var numTicks:Number = 10; // should determine this some other way, I think

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/41410049/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/VerticalCategoryAxisBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/VerticalCategoryAxisBead.as
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/VerticalCategoryAxisBead.as
index f898f18..b7efe27 100644
--- a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/VerticalCategoryAxisBead.as
+++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/VerticalCategoryAxisBead.as
@@ -136,6 +136,22 @@ package org.apache.flex.charts.beads
 		/**
 		 * @private
 		 */
+		public function get maximum():Number
+		{
+			return Number.NaN;
+		}
+		
+		/**
+		 * @private
+		 */
+		public function get minimum():Number
+		{
+			return 0;
+		}
+		
+		/**
+		 * @private
+		 */
 		private function handleItemsCreated(event:Event):void
 		{	
 			var model:ArraySelectionModel = strand.getBeadByType(ISelectionModel) as ArraySelectionModel;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/41410049/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/VerticalLinearAxisBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/VerticalLinearAxisBead.as
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/VerticalLinearAxisBead.as
index 4223743..20546f4 100644
--- a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/VerticalLinearAxisBead.as
+++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/VerticalLinearAxisBead.as
@@ -77,7 +77,7 @@ package org.apache.flex.charts.beads
 		
 		/**
 		 *  The name of field within the chart data the holds the value being mapped
-		 *  to this axis. If values should fall within minValue and maxValue but if
+		 *  to this axis. If values should fall within minimum and maximum but if
 		 *  not, they will be fixed to the closest value.
 		 *
 		 *  @langversion 3.0
@@ -94,10 +94,10 @@ package org.apache.flex.charts.beads
 			_valueField = value;
 		}
 		
-		private var _minValue:Number = Number.NaN;
+		private var _minimum:Number = 0;
 		
 		/**
-		 *  The minimun value to be represented on this axis. If minValue is NaN,
+		 *  The minimun value to be represented on this axis. If minimum is NaN,
 		 *  the value is calculated from the data.
 		 *
 		 *  @langversion 3.0
@@ -105,19 +105,19 @@ package org.apache.flex.charts.beads
 		 *  @playerversion AIR 2.6
 		 *  @productversion FlexJS 0.0
 		 */
-		public function get minValue():Number
+		public function get minimum():Number
 		{
-			return _minValue;
+			return _minimum;
 		}
-		public function set minValue(value:Number):void
+		public function set minimum(value:Number):void
 		{
-			_minValue = value;
+			_minimum = value;
 		}
 		
-		private var _maxValue:Number = Number.NaN;
+		private var _maximum:Number = Number.NaN;
 		
 		/**
-		 *  The maximum value to be represented on this axis. If maxValue is NaN,
+		 *  The maximum value to be represented on this axis. If maximum is NaN,
 		 *  the value is calculated from the data.
 		 *
 		 *  @langversion 3.0
@@ -125,13 +125,13 @@ package org.apache.flex.charts.beads
 		 *  @playerversion AIR 2.6
 		 *  @productversion FlexJS 0.0
 		 */
-		public function get maxValue():Number
+		public function get maximum():Number
 		{
-			return _maxValue;
+			return _maximum;
 		}
-		public function set maxValue(value:Number):void
+		public function set maximum(value:Number):void
 		{
-			_maxValue = value;
+			_maximum = value;
 		}
 		
 		/**
@@ -173,29 +173,34 @@ package org.apache.flex.charts.beads
 			var useWidth:Number  = UIBase(axisGroup).width;
 			var xpos:Number = 0;
 			var ypos:Number = useHeight;
+			var minValue:Number = Number.MAX_VALUE;
+			var maxValue:Number = Number.MIN_VALUE;
 			
 			// determine minimum and maximum values, if needed
-			if (isNaN(minValue)) {
-				minValue = Number.MAX_VALUE;
+			if (isNaN(minimum)) {
 				for(var i:int=0; i < items.length; i++) {
 					var value:Number = Number(items[i][valueField]);
 					if (!isNaN(value)) minValue = Math.min(minValue,value);
 					else minValue = Math.min(minValue,0);
 				}
+			} else {
+				minValue = minimum;
 			}
-			if (isNaN(maxValue)) {
-				maxValue = Number.MIN_VALUE;
+			if (isNaN(maximum)) {
 				for(i=0; i < items.length; i++) {
 					value = Number(items[i][valueField]);
 					if (!isNaN(value)) maxValue = Math.max(maxValue,value);
 					else maxValue = Math.max(maxValue,0);
 				}
+			} else {
+				maxValue = maximum;
 			}
 			
+			var range:Number = maxValue - minValue;
 			var numTicks:Number = 10; // should determine this some other way, I think
-			var tickStep:Number = (maxValue - minValue)/numTicks;
+			var tickStep:Number = range/numTicks;
 			var tickSpacing:Number = useHeight/numTicks;
-			var tickValue:Number = minValue;
+			var tickValue:Number = minimum;
 			
 			// place the labels below the axis enough to account for the tick marks
 			var labelY:Number = UIBase(axisGroup).height + 8;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/41410049/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/BarChartLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/BarChartLayout.as
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/BarChartLayout.as
index e4b0aa1..076fb0a 100644
--- a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/BarChartLayout.as
+++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/BarChartLayout.as
@@ -91,12 +91,21 @@ package org.apache.flex.charts.beads.layouts
 			var ypos:Number = useHeight;
 			
 			var maxXValue:Number = 0;
-			var seriesMaxes:Array = [];
+			var minXValue:Number = 0;
+			var scaleFactor:Number = 1.0;
+			var determineScale:Boolean = true;
+			
+			if (horizontalAxisBead != null && !isNaN(horizontalAxisBead.maximum)) {
+				maxXValue = horizontalAxisBead.maximum;
+				determineScale = false;
+			}
+			if (horizontalAxisBead != null && !isNaN(horizontalAxisBead.minimum)) {
+				minXValue = horizontalAxisBead.minimum;
+			}
 			
 			for (var s:int = 0; s < chart.series.length; s++)
 			{
 				var bcs:BarSeries = chart.series[s] as BarSeries;
-				seriesMaxes.push({maxValue:0,scaleFactor:0});
 				
 				for (var i:int = 0; i < n; i++)
 				{
@@ -104,12 +113,13 @@ package org.apache.flex.charts.beads.layouts
 					var field:String = bcs.xField;
 					
 					var xValue:Number = Number(data[field]);
-					seriesMaxes[s].maxValue = Math.max(seriesMaxes[s].maxValue,xValue);
-				}
-				
-				seriesMaxes[s].scaleFactor = useWidth/seriesMaxes[s].maxValue;
+					if (determineScale) maxXValue = Math.max(xValue, maxXValue);
+				}				
 			}
 			
+			var range:Number = maxXValue - minXValue;
+			scaleFactor = useWidth/range;
+			
 			for (i = 0; i < n; i++)
 			{
 				data = dp[i];
@@ -119,11 +129,13 @@ package org.apache.flex.charts.beads.layouts
 					bcs = chart.series[s] as BarSeries;
 					
 					var child:IChartItemRenderer = chartDataGroup.getItemRendererForSeriesAtIndex(bcs,i);
-					xValue = Number(data[bcs.xField]);
+					xValue = Number(data[bcs.xField]) - minXValue;
+					if (xValue > maxXValue) xValue = maxXValue;
+					xValue = xValue * scaleFactor;
 					
 					child.x = 0;
 					child.y = ypos - seriesHeight;
-					child.width = xValue*seriesMaxes[s].scaleFactor;
+					child.width = xValue;
 					child.height = seriesHeight;
 					ypos -= seriesHeight;
 				}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/41410049/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/ColumnChartLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/ColumnChartLayout.as
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/ColumnChartLayout.as
index d7a4784..0d8c019 100644
--- a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/ColumnChartLayout.as
+++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/ColumnChartLayout.as
@@ -20,6 +20,7 @@ package org.apache.flex.charts.beads.layouts
 {
 	import org.apache.flex.charts.core.ICartesianChartLayout;
 	import org.apache.flex.charts.core.IChartItemRenderer;
+	import org.apache.flex.charts.core.IVerticalAxisBead;
 	import org.apache.flex.charts.supportClasses.ColumnSeries;
 	import org.apache.flex.core.IBeadLayout;
 	import org.apache.flex.core.ISelectionModel;
@@ -81,12 +82,21 @@ package org.apache.flex.charts.beads.layouts
 			var seriesWidth:Number = itemWidth/chart.series.length;
 			
 			var maxYValue:Number = 0;
-			var seriesMaxes:Array = [];
+			var minYValue:Number = 0;
+			var scaleFactor:Number = 1;
+			var determineScale:Boolean = true;
+			
+			if (verticalAxisBead != null && !isNaN(verticalAxisBead.maximum)) {
+				maxYValue = verticalAxisBead.maximum;
+				determineScale = false;
+			}
+			if (verticalAxisBead != null && !isNaN(verticalAxisBead.minimum)) {
+				minYValue = verticalAxisBead.minimum;
+			}
 			
 			for (var s:int = 0; s < chart.series.length; s++)
 			{
-				var bcs:ColumnSeries = chart.series[s] as ColumnSeries;
-				seriesMaxes.push({maxValue:0,scaleFactor:0});
+				var bcs:ColumnSeries = chart.series[s] as ColumnSeries;				
 				
 				for (var i:int = 0; i < n; i++)
 				{
@@ -94,12 +104,13 @@ package org.apache.flex.charts.beads.layouts
 					var field:String = bcs.yField;
 					
 					var yValue:Number = Number(data[field]);
-					seriesMaxes[s].maxValue = Math.max(seriesMaxes[s].maxValue,yValue);
+					if (determineScale) maxYValue = Math.max(yValue, maxYValue);
 				}
-				
-				seriesMaxes[s].scaleFactor = useHeight/seriesMaxes[s].maxValue;
 			}
 			
+			var range:Number = maxYValue - minYValue;
+			scaleFactor = useHeight/range;
+			
 			for (i = 0; i < n; i++)
 			{
 				data = dp[i];
@@ -109,12 +120,14 @@ package org.apache.flex.charts.beads.layouts
 					bcs = chart.series[s] as ColumnSeries;
 					
 					var child:IChartItemRenderer = chartDataGroup.getItemRendererForSeriesAtIndex(bcs,i);
-					yValue = Number(data[bcs.yField]);
+					yValue = Number(data[bcs.yField]) - minYValue;
+					if (yValue > maxYValue) yValue = maxYValue;
+					yValue = yValue * scaleFactor;
 					
-					child.y = useHeight - yValue*seriesMaxes[s].scaleFactor;
+					child.y = useHeight - yValue;
 					child.x = xpos;
 					child.width = seriesWidth;
-					child.height = yValue*seriesMaxes[s].scaleFactor;
+					child.height = yValue;
 					xpos += seriesWidth;
 				}
 				

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/41410049/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/LineChartCategoryVsLinearLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/LineChartCategoryVsLinearLayout.as
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/LineChartCategoryVsLinearLayout.as
index acf33b8..8a15003 100644
--- a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/LineChartCategoryVsLinearLayout.as
+++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/LineChartCategoryVsLinearLayout.as
@@ -64,12 +64,23 @@ package org.apache.flex.charts.beads.layouts
 			var itemWidth:Number =  useWidth/dp.length;
 			
 			var maxYValue:Number = 0;
-			var seriesMaxes:Array = [];
+			var minYValue:Number = 0;
+			var scaleYFactor:Number = 1;
+			var determineYScale:Boolean = true;
+			var seriesPoints:Array = [];
+			
+			if (verticalAxisBead != null && !isNaN(verticalAxisBead.maximum)) {
+				maxYValue = verticalAxisBead.maximum;
+				determineYScale = false;
+			}
+			if (verticalAxisBead != null && !isNaN(verticalAxisBead.minimum)) {
+				minYValue = verticalAxisBead.minimum;
+			}
 			
 			for (var s:int = 0; s < chart.series.length; s++)
 			{
 				var aseries:IChartSeries = chart.series[s] as IChartSeries;
-				seriesMaxes.push({maxValue:0,scaleFactor:0,points:[]});
+				seriesPoints.push({points:[]});
 				
 				for (var i:int = 0; i < n; i++)
 				{
@@ -77,12 +88,12 @@ package org.apache.flex.charts.beads.layouts
 					var field:String = aseries.yField;
 					
 					var yValue:Number = Number(data[field]);
-					seriesMaxes[s].maxValue = Math.max(seriesMaxes[s].maxValue,yValue);
-				}
-				
-				seriesMaxes[s].scaleFactor = useHeight/seriesMaxes[s].maxValue;
+					if (determineYScale) maxYValue = Math.max(maxYValue,yValue);
+				}				
 			}
 			
+			scaleYFactor = useHeight/(maxYValue - minYValue);
+			
 			// draw the itemRenderers at each vertex and build the points array for the
 			// line segment.
 			
@@ -95,12 +106,12 @@ package org.apache.flex.charts.beads.layouts
 				for (i=0; i < n; i++)
 				{
 					data = dp[i];
-					yValue = Number(data[aseries.yField]);
+					yValue = Number(data[aseries.yField]) - minYValue;
 					
 					var childX:Number = xpos;
-					var childY:Number = useHeight - yValue*seriesMaxes[s].scaleFactor;
+					var childY:Number = useHeight - yValue*scaleYFactor;
 					
-					seriesMaxes[s].points.push( {x:childX, y:childY} );
+					seriesPoints[s].points.push( {x:childX, y:childY} );
 					
 					var child:IChartItemRenderer = chartDataGroup.getItemRendererForSeriesAtIndex(aseries,i);
 					if (child) {
@@ -126,7 +137,7 @@ package org.apache.flex.charts.beads.layouts
 					chartDataGroup.addElement(renderer);
 					renderer.itemRendererParent = chartDataGroup;
 					renderer.data = lcs;
-					renderer.points = seriesMaxes[s].points;
+					renderer.points = seriesPoints[s].points;
 				}
 			}
 			

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/41410049/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/LineChartLinearVsLinearLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/LineChartLinearVsLinearLayout.as
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/LineChartLinearVsLinearLayout.as
index 54769e5..6719aa0 100644
--- a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/LineChartLinearVsLinearLayout.as
+++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/LineChartLinearVsLinearLayout.as
@@ -55,23 +55,44 @@ package org.apache.flex.charts.beads.layouts
 				return;
 			
 			var n:int = dp.length;
-			var xAxisOffset:Number = 0;
-			var yAxisOffset:Number = 0;
 			
-			var xpos:Number = yAxisOffset;
-			var ypos:Number = xAxisOffset;
-			var useWidth:Number = UIBase(chartDataGroup).width - yAxisOffset;;
-			var useHeight:Number = UIBase(chartDataGroup).height - xAxisOffset;
+			var xpos:Number = 0;
+			var ypos:Number = 0;
+			var useWidth:Number = UIBase(chartDataGroup).width;
+			var useHeight:Number = UIBase(chartDataGroup).height;
 			var itemWidth:Number =  useWidth/dp.length;
 			
-			var seriesMaxes:Array = [];
+			var maxXValue:Number = 0;
+			var minXValue:Number = 0;
+			var maxYValue:Number = 0;
+			var minYValue:Number = 0;
+			var scaleXFactor:Number = 1;
+			var scaleYFactor:Number = 1;
+			var determineYScale:Boolean = true;
+			var determineXScale:Boolean = true;
+			
+			if (horizontalAxisBead != null && !isNaN(horizontalAxisBead.maximum)) {
+				maxXValue = horizontalAxisBead.maximum;
+				determineXScale = false;
+			}
+			if (horizontalAxisBead != null && !isNaN(horizontalAxisBead.minimum)) {
+				minXValue = horizontalAxisBead.minimum;
+			}
+			
+			if (verticalAxisBead != null && !isNaN(verticalAxisBead.maximum)) {
+				maxYValue = verticalAxisBead.maximum;
+				determineYScale = false;
+			}
+			if (verticalAxisBead != null && !isNaN(verticalAxisBead.minimum)) {
+				minYValue = verticalAxisBead.minimum;
+			}
+			
+			var seriesPoints:Array = [];
 			
 			for (var s:int = 0; s < chart.series.length; s++)
 			{
 				var aseries:IChartSeries = chart.series[s] as IChartSeries;
-				seriesMaxes.push({minX:Number.MAX_VALUE,maxX:Number.MIN_VALUE,
-					              minY:Number.MAX_VALUE,maxY:Number.MIN_VALUE,
-								  scaleX:0,scaleY:0,points:[]});
+				seriesPoints.push({points:[]});
 				
 				for (var i:int = 0; i < n; i++)
 				{
@@ -80,17 +101,16 @@ package org.apache.flex.charts.beads.layouts
 					var yfield:String = aseries.yField;
 					
 					var xValue:Number = Number(data[xfield]);
-					seriesMaxes[s].minX = Math.min(seriesMaxes[s].minX,xValue);
-					seriesMaxes[s].maxX = Math.max(seriesMaxes[s].maxX,xValue);
+					if (determineXScale) maxXValue = Math.max(maxXValue, xValue);
+
 					var yValue:Number = Number(data[yfield]);
-					seriesMaxes[s].minY = Math.min(seriesMaxes[s].minY,yValue);
-					seriesMaxes[s].maxY = Math.max(seriesMaxes[s].maxY,yValue);
+					if (determineYScale) maxYValue = Math.max(maxYValue, yValue);
 				}
-				
-				seriesMaxes[s].scaleX = useWidth/(seriesMaxes[s].maxX - seriesMaxes[s].minX);
-				seriesMaxes[s].scaleY = useHeight/(seriesMaxes[s].maxY - seriesMaxes[s].minY);
 			}
 			
+			scaleXFactor = useWidth / (maxXValue - minXValue);
+			scaleYFactor = useHeight / (maxYValue - minYValue);
+			
 			// draw the itemRenderers at each vertex and build the points array for the
 			// line segment.
 			
@@ -101,13 +121,13 @@ package org.apache.flex.charts.beads.layouts
 				for (i=0; i < n; i++)
 				{
 					data = dp[i];
-					xValue = Number(data[aseries.xField]);
-					yValue = Number(data[aseries.yField]);
+					xValue = Number(data[aseries.xField]) - minXValue;
+					yValue = Number(data[aseries.yField]) - minYValue;
 					
-					var childX:Number = (xValue-seriesMaxes[s].minX)*seriesMaxes[s].scaleX + yAxisOffset;
-					var childY:Number = useHeight - (yValue-seriesMaxes[s].minY)*seriesMaxes[s].scaleY;
+					var childX:Number = (xValue*scaleXFactor);
+					var childY:Number = useHeight - (yValue*scaleYFactor);
 					
-					seriesMaxes[s].points.push( {x:childX, y:childY} );
+					seriesPoints[s].points.push( {x:childX, y:childY} );
 					
 					var child:IChartItemRenderer = chartDataGroup.getItemRendererForSeriesAtIndex(aseries,i);
 					if (child) {
@@ -131,7 +151,7 @@ package org.apache.flex.charts.beads.layouts
 					chartDataGroup.addElement(renderer);
 					renderer.itemRendererParent = chartDataGroup;
 					renderer.data = lcs;
-					renderer.points = seriesMaxes[s].points;
+					renderer.points = seriesPoints[s].points;
 				}
 			}
 			

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/41410049/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/StackedBarChartLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/StackedBarChartLayout.as
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/StackedBarChartLayout.as
index 2fafb29..07bb720 100644
--- a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/StackedBarChartLayout.as
+++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/StackedBarChartLayout.as
@@ -84,6 +84,8 @@ package org.apache.flex.charts.beads.layouts
 			
 			var n:int = dp.length;			
 			var maxXValue:Number = 0;
+			var minXValue:Number = 0;
+			var determineScale:Boolean = true;
 			var seriesMaxes:Array = [];
 			
 			var useWidth:Number = UIBase(chartDataGroup).width;
@@ -94,9 +96,16 @@ package org.apache.flex.charts.beads.layouts
 			var ypos:Number = useHeight;
 			
 			var barValues:Array = [];
-			var maxValue:Number = 0;
 			var scaleFactor:Number = 1;
 			
+			if (horizontalAxisBead != null && !isNaN(horizontalAxisBead.maximum)) {
+				maxXValue = horizontalAxisBead.maximum;
+				determineScale = false;
+			}
+			if (horizontalAxisBead != null && !isNaN(horizontalAxisBead.minimum)) {
+				minXValue = horizontalAxisBead.minimum;
+			}
+			
 			for (var i:int=0; i < n; i++)
 			{
 				barValues.push({totalValue:0, scaleFactor:0});
@@ -112,10 +121,12 @@ package org.apache.flex.charts.beads.layouts
 					barValues[i].totalValue += xValue;
 				}
 				
-				maxValue = Math.max(maxValue, barValues[i].totalValue);
+				if (determineScale) {
+					maxXValue = Math.max(maxXValue, barValues[i].totalValue);
+				}
 			}
 			
-			scaleFactor = useWidth/maxValue;
+			scaleFactor = useWidth/(maxXValue - minXValue);
 			
 			for (i=0; i < n; i++)
 			{
@@ -128,14 +139,15 @@ package org.apache.flex.charts.beads.layouts
 					bcs = chart.series[s] as BarSeries;
 					
 					var child:IChartItemRenderer = chartDataGroup.getItemRendererForSeriesAtIndex(bcs,i);
-					xValue = Number(data[bcs.xField]);
+					xValue = Number(data[bcs.xField]) - minXValue;
+					xValue = xValue * scaleFactor;
 					
 					child.x = xpos;
-					child.width = xValue*scaleFactor;
-					child.y = ypos - seriesHeight;
+					child.width = Math.floor(xValue);
+					child.y = Math.floor(ypos - seriesHeight);
 					child.height = seriesHeight;
 					
-					xpos += xValue*scaleFactor;
+					xpos += xValue;
 				}
 				
 				ypos -= (itemHeight + gap);

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/41410049/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/StackedColumnChartLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/StackedColumnChartLayout.as
b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/StackedColumnChartLayout.as
index b09ff9f..074f82d 100644
--- a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/StackedColumnChartLayout.as
+++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/StackedColumnChartLayout.as
@@ -90,14 +90,23 @@ package org.apache.flex.charts.beads.layouts
 			var ypos:Number = 0;
 			
 			var maxYValue:Number = 0;
+			var minYValue:Number = 0;
+			var determineScale:Boolean = true;
 			
 			var barValues:Array = [];
-			var maxValue:Number = 0;
 			var scaleFactor:Number = 1;
 			
+			if (verticalAxisBead != null && !isNaN(verticalAxisBead.maximum)) {
+				maxYValue = verticalAxisBead.maximum;
+				determineScale = false;
+			}
+			if (verticalAxisBead != null && !isNaN(verticalAxisBead.minimum)) {
+				minYValue = verticalAxisBead.minimum;
+			}
+			
 			for (var i:int=0; i < n; i++)
 			{
-				barValues.push({totalValue:0, scaleFactor:0});
+				barValues.push({totalValue:0});
 				var data:Object = dp[i];
 				
 				for (var s:int = 0; s < chart.series.length; s++)
@@ -109,10 +118,12 @@ package org.apache.flex.charts.beads.layouts
 					barValues[i].totalValue += yValue;
 				}
 				
-				maxValue = Math.max(maxValue, barValues[i].totalValue);
+				if (determineScale) {
+					maxYValue = Math.max(maxYValue, barValues[i].totalValue);
+				}
 			}
 			
-			scaleFactor = useHeight/maxValue;
+			scaleFactor = useHeight / (maxYValue - minYValue);
 			
 			for (i=0; i < n; i++)
 			{
@@ -124,12 +135,14 @@ package org.apache.flex.charts.beads.layouts
 					bcs = chart.series[s] as ColumnSeries;
 
 					var child:IChartItemRenderer = chartDataGroup.getItemRendererForSeriesAtIndex(bcs,i);
-					yValue = Math.floor(Number(data[bcs.yField]));
+					
+					yValue = Number(data[field]) - minYValue;
+					yValue = yValue * scaleFactor;
 					
 					child.x = xpos;
 					child.width = itemWidth;
-					child.y = ypos - Math.ceil(yValue*scaleFactor);
-					child.height = Math.floor(yValue*scaleFactor);
+					child.y = ypos - Math.ceil(yValue);
+					child.height = Math.floor(yValue);
 					
 					ypos = child.y;
 				}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/41410049/frameworks/as/projects/FlexJSUI/src/org/apache/flex/charts/core/IHorizontalAxisBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/charts/core/IHorizontalAxisBead.as
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/charts/core/IHorizontalAxisBead.as
index a1795ae..0845cde 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/charts/core/IHorizontalAxisBead.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/charts/core/IHorizontalAxisBead.as
@@ -39,5 +39,27 @@ package org.apache.flex.charts.core
 		 */
 		function get axisHeight():Number;
 		function set axisHeight(value:Number):void;
+		
+		/**
+		 *  The explicit maximum value being represented by this axis. If
+		 *  this value is not set, NaN is returned. 
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		function get maximum():Number;
+		
+		/**
+		 *  The explicit minimum value being represented by this axis. If
+		 *  this value is not set, 0 is returned. 
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		function get minimum():Number;
 	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/41410049/frameworks/as/projects/FlexJSUI/src/org/apache/flex/charts/core/IVerticalAxisBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/charts/core/IVerticalAxisBead.as
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/charts/core/IVerticalAxisBead.as
index 4fd76ef..be6a05f 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/charts/core/IVerticalAxisBead.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/charts/core/IVerticalAxisBead.as
@@ -39,5 +39,27 @@ package org.apache.flex.charts.core
 		 */
 		function get axisWidth():Number;
 		function set axisWidth(value:Number):void;
+		
+		/**
+		 *  The explicit maximum value being represented by this axis. If
+		 *  this value is not set, NaN is returned. 
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		function get maximum():Number;
+		
+		/**
+		 *  The explicit minimum value being represented by this axis. If
+		 *  this value is not set, 0 is returned. 
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		function get minimum():Number;
 	}
 }
\ No newline at end of file


Mime
View raw message