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] - Added VerticalLinearAxisBead and HorizontalLinearAxisBead to the chart portion of the FlexJS SDK. Adjusted the chart layouts to allow for two axes.
Date Tue, 26 Aug 2014 20:56:51 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop 18397679d -> 4677f8524


Added VerticalLinearAxisBead and HorizontalLinearAxisBead to the chart portion of the FlexJS
SDK. Adjusted the chart layouts to allow for two axes.


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

Branch: refs/heads/develop
Commit: 4677f85244cb55badfbc14e70042847d4c7cf8ef
Parents: 1839767
Author: Peter Ent <pent@apache.org>
Authored: Tue Aug 26 16:56:47 2014 -0400
Committer: Peter Ent <pent@apache.org>
Committed: Tue Aug 26 16:56:47 2014 -0400

----------------------------------------------------------------------
 .../as/projects/FlexJSJX/basic-manifest.xml     |   2 +
 .../as/projects/FlexJSJX/src/FlexJSJXClasses.as |   2 +
 .../charts/beads/HorizontalCategoryAxisBead.as  |  13 +-
 .../charts/beads/HorizontalLinearAxisBead.as    | 284 +++++++++++++++++++
 .../charts/beads/VerticalCategoryAxisBead.as    |  11 +-
 .../flex/charts/beads/VerticalLinearAxisBead.as | 271 ++++++++++++++++++
 .../flex/charts/beads/layouts/BarChartLayout.as |   2 +-
 .../charts/beads/layouts/ColumnChartLayout.as   |   2 +-
 .../beads/layouts/StackedBarChartLayout.as      |   2 +-
 .../beads/layouts/StackedColumnChartLayout.as   |   2 +-
 10 files changed, 580 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4677f852/frameworks/as/projects/FlexJSJX/basic-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSJX/basic-manifest.xml b/frameworks/as/projects/FlexJSJX/basic-manifest.xml
index e5b969e..d4d6ac6 100644
--- a/frameworks/as/projects/FlexJSJX/basic-manifest.xml
+++ b/frameworks/as/projects/FlexJSJX/basic-manifest.xml
@@ -38,7 +38,9 @@
     <component id="StackedColumnChart" class="org.apache.flex.charts.StackedColumnChart"
/>
     <component id="StackedBarChart" class="org.apache.flex.charts.StackedBarChart" />
     <component id="HorizontalCategoryAxisBead" class="org.apache.flex.charts.beads.HorizontalCategoryAxisBead"
/>
+    <component id="HorizontalLinearAxisBead" class="org.apache.flex.charts.beads.HorizontalLinearAxisBead"
/>
     <component id="VerticalCategoryAxisBead" class="org.apache.flex.charts.beads.VerticalCategoryAxisBead"
/>
+    <component id="VerticalLinearAxisBead" class="org.apache.flex.charts.beads.VerticalLinearAxisBead"
/>
     
     <component id="VerticalColumnLayout" class="org.apache.flex.html.beads.layouts.VerticalColumnLayout"
/>
 

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4677f852/frameworks/as/projects/FlexJSJX/src/FlexJSJXClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSJX/src/FlexJSJXClasses.as b/frameworks/as/projects/FlexJSJX/src/FlexJSJXClasses.as
index 34d0502..19d495e 100644
--- a/frameworks/as/projects/FlexJSJX/src/FlexJSJXClasses.as
+++ b/frameworks/as/projects/FlexJSJX/src/FlexJSJXClasses.as
@@ -31,7 +31,9 @@ internal class FlexJSJXClasses
 	import org.apache.flex.charts.beads.ChartItemRendererFactory; ChartItemRendererFactory;
 	import org.apache.flex.charts.beads.PieChartView; PieChartView;
 	import org.apache.flex.charts.beads.HorizontalCategoryAxisBead; HorizontalCategoryAxisBead;
+	import org.apache.flex.charts.beads.HorizontalLinearAxisBead; HorizontalLinearAxisBead;
 	import org.apache.flex.charts.beads.VerticalCategoryAxisBead; VerticalCategoryAxisBead;
+	import org.apache.flex.charts.beads.VerticalLinearAxisBead; VerticalLinearAxisBead;
 	import org.apache.flex.charts.beads.layouts.BarChartLayout; BarChartLayout;
 	import org.apache.flex.charts.beads.layouts.ColumnChartLayout; ColumnChartLayout;
 	import org.apache.flex.charts.beads.layouts.PieChartLayout; PieChartLayout;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4677f852/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 25bbd6f..c90a861 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
@@ -20,6 +20,7 @@ package org.apache.flex.charts.beads
 {
 	import org.apache.flex.charts.core.IChart;
 	import org.apache.flex.charts.core.IHorizontalAxisBead;
+	import org.apache.flex.charts.core.IVerticalAxisBead;
 	import org.apache.flex.core.FilledRectangle;
 	import org.apache.flex.core.IBead;
 	import org.apache.flex.core.IDataProviderItemRendererMapper;
@@ -150,17 +151,21 @@ package org.apache.flex.charts.beads
 			var renderers:Array = charter.seriesRenderers;
 			var series:Array = IChart(_strand).series;
 			
-			var xpos:Number = 0;
+			var yAxis:IVerticalAxisBead;
+			if (_strand.getBeadByType(IVerticalAxisBead)) yAxis = _strand.getBeadByType(IVerticalAxisBead)
as IVerticalAxisBead;
+			var yAxisOffset:Number = yAxis == null ? 0 : yAxis.axisWidth;
+			
+			var xpos:Number = yAxisOffset;
 			var xAxisHeightOffset:Number = axisHeight;
-			var useWidth:Number = UIBase(_strand).width / renderers.length;
+			var useWidth:Number = (UIBase(_strand).width-yAxisOffset) / renderers.length;
 			
 			// draw the horzontal axis
 			var horzLine:FilledRectangle = new FilledRectangle();
 			horzLine.fillColor = 0x111111;
-			horzLine.x = 0;
+			horzLine.x = xpos;
 			horzLine.y = UIBase(_strand).height - xAxisHeightOffset;
 			horzLine.height = 1;
-			horzLine.width = UIBase(_strand).width;
+			horzLine.width = UIBase(_strand).width - yAxisOffset;
 			UIBase(_strand).addElement(horzLine);
 			
 			// place the labels below the axis enough to account for the tick marks

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4677f852/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
new file mode 100644
index 0000000..7f73536
--- /dev/null
+++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/HorizontalLinearAxisBead.as
@@ -0,0 +1,284 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.charts.beads
+{
+	import org.apache.flex.charts.core.IChart;
+	import org.apache.flex.charts.core.IHorizontalAxisBead;
+	import org.apache.flex.charts.core.IVerticalAxisBead;
+	import org.apache.flex.core.FilledRectangle;
+	import org.apache.flex.core.IBead;
+	import org.apache.flex.core.IDataProviderItemRendererMapper;
+	import org.apache.flex.core.ISelectionModel;
+	import org.apache.flex.core.IStrand;
+	import org.apache.flex.core.UIBase;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.IEventDispatcher;
+	import org.apache.flex.html.Label;
+	import org.apache.flex.html.beads.models.ArraySelectionModel;
+	
+	/**
+	 *  The HorizontalLinearAxisBead class provides a horizontal axis that uses a numeric
+	 *  range. 
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion FlexJS 0.0
+	 */
+	public class HorizontalLinearAxisBead implements IBead, IHorizontalAxisBead
+	{
+		/**
+		 *  constructor.
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function HorizontalLinearAxisBead()
+		{
+		}
+		
+		private var _axisHeight:Number = 30;
+		
+		/**
+		 *  The height of the horizontal axis.
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function get axisHeight():Number
+		{
+			return _axisHeight;
+		}
+		public function set axisHeight(value:Number):void
+		{
+			_axisHeight = value;
+		}
+		
+		private var _valueField:String;
+		
+		/**
+		 *  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
+		 *  not, they will be fixed to the closest value.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function get valueField():String
+		{
+			return _valueField;
+		}
+		public function set valueField(value:String):void
+		{
+			_valueField = value;
+		}
+		
+		private var _minValue:Number = Number.NaN;
+		
+		/**
+		 *  The minimun value to be represented on this axis. If minValue is NaN,
+		 *  the value is calculated from the data.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function get minValue():Number
+		{
+			return _minValue;
+		}
+		public function set minValue(value:Number):void
+		{
+			_minValue = value;
+		}
+		
+		private var _maxValue:Number = Number.NaN;
+		
+		/**
+		 *  The maximum value to be represented on this axis. If maxValue is NaN,
+		 *  the value is calculated from the data.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function get maxValue():Number
+		{
+			return _maxValue;
+		}
+		public function set maxValue(value:Number):void
+		{
+			_maxValue = value;
+		}
+		
+		private var _gap:Number = 20;
+		
+		/**
+		 *  The amount of space to leave between series. If a chart has several series,
+		 *  the bars for an X value are side by side with a gap between the groups of
+		 *  bars.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function get gap():Number
+		{
+			return _gap;
+		}
+		public function set gap(value:Number):void
+		{
+			_gap = value;
+		}
+		
+		private var _strand:IStrand;
+		
+		/**
+		 *  @copy org.apache.flex.core.IBead#strand
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function set strand(value:IStrand):void
+		{
+			_strand = value;
+			
+			// in order to draw or create the labels, need to know when the series has been created.
+			IEventDispatcher(_strand).addEventListener("layoutComplete",handleItemsCreated);
+		}
+		
+		/**
+		 * @private
+		 */
+		private function formatLabel(n:Number):String
+		{
+			var sign:Number = n < 0 ? -1 : 1;
+			n = Math.abs(n);
+			
+			var i:int;
+			
+			if (0 <= n && n <= 1) {
+				i = Math.round(n * 100);
+				n = i / 100.0;
+			}
+			else {
+				i = Math.round(n);
+				n = i;
+			}
+			
+			var result:String = String(sign*n);
+			return result;
+		}
+		
+		/**
+		 * @private
+		 */
+		private function handleItemsCreated(event:Event):void
+		{
+			var charter:ChartItemRendererFactory =
+				_strand.getBeadByType(IDataProviderItemRendererMapper) as ChartItemRendererFactory;
+			
+			var model:ArraySelectionModel = _strand.getBeadByType(ISelectionModel) as ArraySelectionModel;
+			var items:Array;
+			if (model.dataProvider is Array) items = model.dataProvider as Array;
+			else return;
+			
+			var renderers:Array = charter.seriesRenderers;
+			var series:Array = IChart(_strand).series;
+			
+			var yAxis:IVerticalAxisBead;
+			if (_strand.getBeadByType(IVerticalAxisBead)) yAxis = _strand.getBeadByType(IVerticalAxisBead)
as IVerticalAxisBead;
+			var yAxisOffset:Number = yAxis == null ? 0 : yAxis.axisWidth;
+			
+			var xpos:Number = yAxisOffset;
+			var xAxisHeightOffset:Number = axisHeight;
+			var useWidth:Number = UIBase(_strand).width - yAxisOffset;
+			
+			// draw the horzontal axis
+			var horzLine:FilledRectangle = new FilledRectangle();
+			horzLine.fillColor = 0x111111;
+			horzLine.x = xpos;
+			horzLine.y = UIBase(_strand).height - xAxisHeightOffset;
+			horzLine.height = 1;
+			horzLine.width = useWidth;
+			UIBase(_strand).addElement(horzLine);
+			
+			// place the labels below the axis enough to account for the tick marks
+			var labelY:Number = UIBase(_strand).height + 8;
+			
+			// determine minimum and maximum values, if needed
+			if (isNaN(minValue)) {
+				minValue = Number.MAX_VALUE;
+				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);
+				}
+			}
+			if (isNaN(maxValue)) {
+				maxValue = Number.MIN_VALUE;
+				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);
+				}
+			}
+			
+			var numTicks:Number = 10; // should determine this some other way, I think
+			var tickStep:Number = (maxValue - minValue)/numTicks;
+			var tickSpacing:Number = useWidth/numTicks;
+			var tickValue:Number = minValue;
+			
+			// adjust xpos to the first tick position
+			xpos += tickSpacing;
+			
+			for(i=0; i < numTicks; i++) {				
+				var label:Label = new Label();
+				label.text = formatLabel(tickValue);
+				label.x = xpos - label.width/2;
+				label.y = labelY - xAxisHeightOffset;
+				
+				UIBase(_strand).addElement(label);
+				
+				// add a tick mark, too
+				var tick:FilledRectangle = new FilledRectangle();
+				tick.fillColor = 0x111111;
+				tick.x = xpos;
+				tick.y = UIBase(_strand).height - xAxisHeightOffset;
+				tick.width = 1;
+				tick.height = 5;
+				UIBase(_strand).addElement(tick);
+				
+				xpos += tickSpacing;
+				tickValue += tickStep;
+			}
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4677f852/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 6b907fc..b28a21a 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
@@ -19,6 +19,7 @@
 package org.apache.flex.charts.beads
 {
 	import org.apache.flex.charts.core.IChart;
+	import org.apache.flex.charts.core.IHorizontalAxisBead;
 	import org.apache.flex.charts.core.IVerticalAxisBead;
 	import org.apache.flex.core.FilledRectangle;
 	import org.apache.flex.core.IBead;
@@ -151,18 +152,22 @@ package org.apache.flex.charts.beads
 			var renderers:Array = charter.seriesRenderers;
 			var series:Array = IChart(_strand).series;
 			
+			var xAxis:IHorizontalAxisBead;
+			if (_strand.getBeadByType(IHorizontalAxisBead)) xAxis = _strand.getBeadByType(IHorizontalAxisBead)
as IHorizontalAxisBead;
+			var xAxisOffset:Number = xAxis == null ? 0 : xAxis.axisHeight;
+			
 			var yAxisWidthOffset:Number = axisWidth;
-			var useHeight:Number = UIBase(_strand).height / renderers.length;
+			var useHeight:Number = (UIBase(_strand).height-xAxisOffset) / renderers.length;
 			var seriesHeight:Number = useHeight/series.length;
 			var xpos:Number = yAxisWidthOffset;
-			var ypos:Number = UIBase(_strand).height - seriesHeight - gap;
+			var ypos:Number = UIBase(_strand).height - xAxisOffset - seriesHeight - gap;
 			
 			// draw the vertical axis
 			var horzLine:FilledRectangle = new FilledRectangle();
 			horzLine.fillColor = 0x111111;
 			horzLine.x = yAxisWidthOffset;
 			horzLine.y = 0;
-			horzLine.height = UIBase(_strand).height;
+			horzLine.height = UIBase(_strand).height - xAxisOffset;
 			horzLine.width = 1;
 			UIBase(_strand).addElement(horzLine);
 			

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4677f852/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
new file mode 100644
index 0000000..d53527e
--- /dev/null
+++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/VerticalLinearAxisBead.as
@@ -0,0 +1,271 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.charts.beads
+{
+	import org.apache.flex.charts.core.IChart;
+	import org.apache.flex.charts.core.IHorizontalAxisBead;
+	import org.apache.flex.charts.core.IVerticalAxisBead;
+	import org.apache.flex.core.FilledRectangle;
+	import org.apache.flex.core.IBead;
+	import org.apache.flex.core.IDataProviderItemRendererMapper;
+	import org.apache.flex.core.ISelectionModel;
+	import org.apache.flex.core.IStrand;
+	import org.apache.flex.core.UIBase;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.IEventDispatcher;
+	import org.apache.flex.html.Label;
+	import org.apache.flex.html.beads.models.ArraySelectionModel;
+	
+	/**
+	 *  The VerticalLinearAxisBead class provides a vertical axis that uses a numeric
+	 *  range. 
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion FlexJS 0.0
+	 */
+	public class VerticalLinearAxisBead implements IBead, IVerticalAxisBead
+	{
+		public function VerticalLinearAxisBead()
+		{
+		}
+		
+		private var _strand:IStrand;
+		
+		/**
+		 *  @copy org.apache.flex.core.IBead#strand
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function set strand(value:IStrand):void
+		{
+			_strand = value;
+			
+			// in order to draw or create the labels, need to know when the series has been created.
+			IEventDispatcher(_strand).addEventListener("layoutComplete",handleItemsCreated);
+		}
+		
+		private var _axisWidth:Number = 50;
+		
+		public function get axisWidth():Number
+		{
+			return _axisWidth;
+		}
+		public function set axisWidth(value:Number):void
+		{
+			_axisWidth = value;
+		}
+		
+		private var _valueField:String;
+		
+		/**
+		 *  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
+		 *  not, they will be fixed to the closest value.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function get valueField():String
+		{
+			return _valueField;
+		}
+		public function set valueField(value:String):void
+		{
+			_valueField = value;
+		}
+		
+		private var _minValue:Number = Number.NaN;
+		
+		/**
+		 *  The minimun value to be represented on this axis. If minValue is NaN,
+		 *  the value is calculated from the data.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function get minValue():Number
+		{
+			return _minValue;
+		}
+		public function set minValue(value:Number):void
+		{
+			_minValue = value;
+		}
+		
+		private var _maxValue:Number = Number.NaN;
+		
+		/**
+		 *  The maximum value to be represented on this axis. If maxValue is NaN,
+		 *  the value is calculated from the data.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function get maxValue():Number
+		{
+			return _maxValue;
+		}
+		public function set maxValue(value:Number):void
+		{
+			_maxValue = value;
+		}
+		
+		private var _gap:Number = 20;
+		
+		/**
+		 *  The amount of space to leave between series. If a chart has several series,
+		 *  the bars for an X value are side by side with a gap between the groups of
+		 *  bars.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function get gap():Number
+		{
+			return _gap;
+		}
+		public function set gap(value:Number):void
+		{
+			_gap = value;
+		}
+		
+		/**
+		 * @private
+		 */
+		private function formatLabel(n:Number):String
+		{
+			var sign:Number = n < 0 ? -1 : 1;
+			n = Math.abs(n);
+			
+			var i:int;
+			
+			if (0 <= n && n <= 1) {
+				i = Math.round(n * 100);
+				n = i / 100.0;
+			}
+			else {
+				i = Math.round(n);
+				n = i;
+			}
+			
+			var result:String = String(sign*n);
+			return result;
+		}
+		
+		/**
+		 * @private
+		 */
+		private function handleItemsCreated(event:Event):void
+		{
+			var charter:ChartItemRendererFactory =
+				_strand.getBeadByType(IDataProviderItemRendererMapper) as ChartItemRendererFactory;
+			
+			var model:ArraySelectionModel = _strand.getBeadByType(ISelectionModel) as ArraySelectionModel;
+			var items:Array;
+			if (model.dataProvider is Array) items = model.dataProvider as Array;
+			else return;
+			
+			var renderers:Array = charter.seriesRenderers;
+			var series:Array = IChart(_strand).series;
+			
+			var xAxis:IHorizontalAxisBead;
+			if (_strand.getBeadByType(IHorizontalAxisBead)) xAxis = _strand.getBeadByType(IHorizontalAxisBead)
as IHorizontalAxisBead;
+			var xAxisOffset:Number = xAxis == null ? 0 : xAxis.axisHeight;
+			
+			var yAxisWidthOffset:Number = axisWidth;
+			var useHeight:Number = UIBase(_strand).height-xAxisOffset;
+			var xpos:Number = yAxisWidthOffset;
+			var ypos:Number = useHeight;
+			
+			// draw the vertical axis
+			var horzLine:FilledRectangle = new FilledRectangle();
+			horzLine.fillColor = 0x111111;
+			horzLine.x = yAxisWidthOffset;
+			horzLine.y = 0;
+			horzLine.height = useHeight;
+			horzLine.width = 1;
+			UIBase(_strand).addElement(horzLine);
+			
+			// place the labels below the axis enough to account for the tick marks
+			var labelY:Number = UIBase(_strand).height + 8;
+			
+			// determine minimum and maximum values, if needed
+			if (isNaN(minValue)) {
+				minValue = Number.MAX_VALUE;
+				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);
+				}
+			}
+			if (isNaN(maxValue)) {
+				maxValue = Number.MIN_VALUE;
+				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);
+				}
+			}
+			
+			var numTicks:Number = 10; // should determine this some other way, I think
+			var tickStep:Number = (maxValue - minValue)/numTicks;
+			var tickSpacing:Number = useHeight/numTicks;
+			var tickValue:Number = minValue;
+			
+			// adjust ypos to the first tick position
+			ypos = useHeight - tickSpacing;
+			
+			for(i=0; i < numTicks; i++) {				
+				var label:Label = new Label();
+				label.text = formatLabel(tickValue);
+				label.x = 0;
+				label.y = ypos - label.height/2;
+				
+				UIBase(_strand).addElement(label);
+				
+				// add a tick mark, too
+				var tick:FilledRectangle = new FilledRectangle();
+				tick.fillColor = 0x111111;
+				tick.x = xpos - 5;
+				tick.y = ypos;
+				tick.width = 5;
+				tick.height = 1;
+				UIBase(_strand).addElement(tick);
+				
+				ypos -= tickSpacing;
+				tickValue += tickStep;
+			}
+			
+		}
+		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4677f852/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 c05fd49..701d185 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
@@ -106,7 +106,7 @@ package org.apache.flex.charts.beads.layouts
 			var yAxisOffset:Number = yAxis == null ? 0 : yAxis.axisWidth;
 			
 			var useWidth:Number = UIBase(_strand).width - yAxisOffset;
-			var useHeight:Number = (UIBase(_strand).height / n) - gap - xAxisOffset;
+			var useHeight:Number = ((UIBase(_strand).height-xAxisOffset) / n) - gap;
 			var seriesHeight:Number = useHeight/series.length;
 			var xpos:Number = 0;
 			var ypos:Number = UIBase(_strand).height - xAxisOffset - seriesHeight;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4677f852/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 46b884c..19e6f6c 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
@@ -91,7 +91,7 @@ package org.apache.flex.charts.beads.layouts
 			var yAxisOffset:Number = yAxis == null ? 0 : yAxis.axisWidth;
 			
 			var xpos:Number = yAxisOffset;
-			var useWidth:Number = (UIBase(_strand).width / n) - gap - yAxisOffset;
+			var useWidth:Number = ((UIBase(_strand).width-yAxisOffset) / n) - gap;
 			var useHeight:Number = UIBase(_strand).height - xAxisOffset;
 			
 			var maxYValue:Number = 0;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4677f852/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 9b17e5d..24c06cb 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
@@ -118,7 +118,7 @@ package org.apache.flex.charts.beads.layouts
 			var yAxisOffset:Number = yAxis == null ? 0 : yAxis.axisWidth;
 			
 			var useWidth:Number = UIBase(_strand).width - yAxisOffset;
-			var useHeight:Number = (UIBase(_strand).height / n) - gap - xAxisOffset;
+			var useHeight:Number = ((UIBase(_strand).height-xAxisOffset) / n) - gap;
 			var seriesHeight:Number = useHeight;
 			var xpos:Number = xAxisOffset;
 			var ypos:Number = UIBase(_strand).height - xAxisOffset - seriesHeight;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4677f852/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 f3b40d6..857c4bc 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
@@ -114,7 +114,7 @@ package org.apache.flex.charts.beads.layouts
 			
 			var xpos:Number = yAxisOffset;
 			var ypos:Number = 0;
-			var useWidth:Number = (UIBase(_strand).width / n) - gap - yAxisOffset;
+			var useWidth:Number = ((UIBase(_strand).width-yAxisOffset) / n) - gap;
 			var useHeight:Number = UIBase(_strand).height - xAxisOffset;
 			
 			var maxYValue:Number = 0;


Mime
View raw message