You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2015/04/15 23:43:13 UTC
[08/55] [abbrv] git commit: [flex-asjs] [refs/heads/develop] - move
AS classes from FlexJSJX to final home. Build scripts will be fixed up in a
later commit
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b21f62/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/DataTipBead.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/DataTipBead.as b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/DataTipBead.as
new file mode 100644
index 0000000..559a7b9
--- /dev/null
+++ b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/DataTipBead.as
@@ -0,0 +1,162 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.IChartDataGroup;
+ import org.apache.flex.charts.core.IChartItemRenderer;
+ import org.apache.flex.charts.core.IChartSeries;
+ import org.apache.flex.core.IBead;
+ 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.events.MouseEvent;
+ import org.apache.flex.events.utils.MouseUtils;
+ import org.apache.flex.geom.Point;
+ import org.apache.flex.html.accessories.ToolTipBead;
+ import org.apache.flex.html.beads.IListView;
+ import org.apache.flex.utils.PointUtils;
+
+ /**
+ * The DataTipBead can be added to a chart to produce a helpful tip when the
+ * moves over an itemRenderer.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public class DataTipBead extends ToolTipBead implements IBead
+ {
+ /**
+ * Constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function DataTipBead()
+ {
+ }
+
+ private var _strand:IStrand;
+
+ override public function set strand(value:IStrand):void
+ {
+ super.strand = value;
+ _strand = value;
+
+ IEventDispatcher(_strand).addEventListener("viewCreated", handleViewCreated);
+ }
+
+ private var _labelFunction:Function;
+
+ /**
+ * An optional function that can format the data tip text.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function get labelFunction():Function
+ {
+ return _labelFunction;
+ }
+ public function set labelFunction(value:Function):void
+ {
+ _labelFunction = value;
+ }
+
+ /**
+ * @private
+ */
+ private function handleViewCreated( event:Event ):void
+ {
+ // find the data group
+ var chart:IListView = _strand.getBeadByType(IListView) as IListView;
+ var dataGroup:IChartDataGroup = chart.dataGroup as IChartDataGroup;
+ IEventDispatcher(dataGroup).addEventListener(MouseEvent.MOUSE_OVER, rollOverHandler);
+ }
+
+ /**
+ * @private
+ * Overrides the ToolTipBead's function to determine the text to display
+ * based on the chart series and current value.
+ */
+ override protected function rollOverHandler( event:MouseEvent ):void
+ {
+ var renderer:IChartItemRenderer = findItemRenderer(event);
+ if (renderer)
+ {
+ var series:IChartSeries = renderer.series;
+ var result:String;
+
+ if (labelFunction) {
+ result = labelFunction(renderer);
+ }
+ else {
+ if (series.xField) result = renderer.data[series.xField];
+ else if (series.yField) result = renderer.data[series.yField];
+ }
+ this.toolTip = result;
+
+ super.rollOverHandler(event);
+ }
+ }
+
+ /**
+ * @private
+ * Override's the ToolTipBead's function to position the data tip just above
+ * the itemRenderer.
+ */
+ override protected function determinePosition(event:MouseEvent, base:Object):Point
+ {
+ // always want above the renderer
+ var pt:Point = new Point(0, -20);
+ pt = PointUtils.localToGlobal(pt, base);
+ return pt;
+ }
+
+ /**
+ * @private
+ */
+ private function findItemRenderer(event:MouseEvent):IChartItemRenderer
+ {
+ var base:Object = MouseUtils.eventTarget(event);
+
+ if (base is IChartDataGroup)
+ {
+ var dataGroup:IChartDataGroup = base as IChartDataGroup;
+ var point:Point = new Point(event.localX, event.localY);
+ var renderer:IChartItemRenderer = dataGroup.getItemRendererUnderPoint(point);
+ return renderer;
+ }
+ else
+ {
+ var chain:UIBase = base as UIBase;
+ while (chain != null && !(chain is IChartItemRenderer)) {
+ chain = chain.parent as UIBase;
+ }
+ return chain as IChartItemRenderer;
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b21f62/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/HorizontalCategoryAxisBead.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/HorizontalCategoryAxisBead.as b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/HorizontalCategoryAxisBead.as
new file mode 100644
index 0000000..3d54bd4
--- /dev/null
+++ b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/HorizontalCategoryAxisBead.as
@@ -0,0 +1,182 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.IHorizontalAxisBead;
+ import org.apache.flex.core.IBead;
+ 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.beads.models.ArraySelectionModel;
+
+ /**
+ * The HorizontalCategoryAxisBead displays a horizontal axis with
+ * tick marks corresponding to data points identified by the
+ * categoryField property. This type of axis is useful for non-numeric
+ * plots.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public class HorizontalCategoryAxisBead extends AxisBaseBead implements IBead, IHorizontalAxisBead
+ {
+ /**
+ * constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function HorizontalCategoryAxisBead()
+ {
+ super();
+
+ placement = "bottom";
+ }
+
+ 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 _categoryField:String;
+
+ /**
+ * The name of field within the chart data to used to categorize each of the
+ * axis data points.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function get categoryField():String
+ {
+ return _categoryField;
+ }
+ public function set categoryField(value:String):void
+ {
+ _categoryField = 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. The default is 20.
+ *
+ * @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
+ */
+ 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
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ override public function set strand(value:IStrand):void
+ {
+ super.strand = value;
+
+ // in order to draw or create the labels, need to know when the series has been created.
+ IEventDispatcher(value).addEventListener("layoutComplete",handleItemsCreated);
+ }
+
+ /**
+ * @private
+ */
+ private function handleItemsCreated(event:Event):void
+ {
+ var model:ArraySelectionModel = strand.getBeadByType(ISelectionModel) as ArraySelectionModel;
+ var items:Array;
+ if (model.dataProvider is Array) items = model.dataProvider as Array;
+ else return;
+
+ var xpos:Number = 0;
+ var useWidth:Number = UIBase(axisGroup).width;
+
+ // place the labels below the axis enough to account for the tick marks
+ var labelY:Number = 7;
+ var itemWidth:Number = (useWidth - gap*(items.length-1))/items.length;
+
+ for(var i:int=0; i < items.length; i++)
+ {
+ addTickLabel(items[i][categoryField], xpos + itemWidth/2, labelY, itemWidth, 0);
+
+ // add a tick mark, too
+ addTickMark(xpos + itemWidth/2, 0, 0, 5);
+
+ xpos += itemWidth + gap;
+ }
+
+ // draw the axis and the tick marks
+ drawAxisPath(0, 0, useWidth, 1);
+ drawTickPath(0, 1);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b21f62/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/HorizontalLinearAxisBead.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/HorizontalLinearAxisBead.as b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/HorizontalLinearAxisBead.as
new file mode 100644
index 0000000..ddc6174
--- /dev/null
+++ b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/HorizontalLinearAxisBead.as
@@ -0,0 +1,236 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.core.IBead;
+ 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.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 extends AxisBaseBead implements IBead, IHorizontalAxisBead
+ {
+ /**
+ * constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function HorizontalLinearAxisBead()
+ {
+ super();
+
+ placement = "bottom";
+ }
+
+ 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 minimum and maximum 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 _minimum:Number = 0;
+
+ /**
+ * The minimun value to be represented on this axis. If minimum 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 minimum():Number
+ {
+ return _minimum;
+ }
+ public function set minimum(value:Number):void
+ {
+ _minimum = value;
+ }
+
+ private var _maximum:Number = Number.NaN;
+
+ /**
+ * The maximum value to be represented on this axis. If maximum 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 maximum():Number
+ {
+ return _maximum;
+ }
+ public function set maximum(value:Number):void
+ {
+ _maximum = value;
+ }
+
+ /**
+ * @copy org.apache.flex.core.IBead#strand
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ override public function set strand(value:IStrand):void
+ {
+ super.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 model:ArraySelectionModel = strand.getBeadByType(ISelectionModel) as ArraySelectionModel;
+ var items:Array;
+ if (model.dataProvider is Array) items = model.dataProvider as Array;
+ else return;
+
+ 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(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(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
+ var tickStep:Number = (maxValue - minValue)/numTicks;
+ var tickSpacing:Number = useWidth/numTicks;
+ var tickValue:Number = minValue;
+
+ // place the labels below the axis enough to account for the tick marks
+ var labelY:Number = 7;
+
+ for(i=0; i < numTicks+1; i++)
+ {
+ addTickLabel(formatLabel(tickValue), xpos, labelY, tickSpacing, 0);
+
+ // add a tick mark, too
+ addTickMark(xpos, 0, 0, 5);
+
+ xpos += tickSpacing;
+ tickValue += tickStep;
+ }
+
+ // draw the axis and tick marks
+ drawAxisPath(0, 0, useWidth, 0);
+ drawTickPath(0, 1);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b21f62/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/VerticalCategoryAxisBead.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/VerticalCategoryAxisBead.as b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/VerticalCategoryAxisBead.as
new file mode 100644
index 0000000..b7efe27
--- /dev/null
+++ b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/VerticalCategoryAxisBead.as
@@ -0,0 +1,188 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.IVerticalAxisBead;
+ import org.apache.flex.core.IBead;
+ 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.beads.models.ArraySelectionModel;
+
+ /**
+ * The VerticalCategoryAxisBead displays a vertical axis with
+ * tick marks corresponding to data points identified by the
+ * categoryField property. This type of axis is useful for non-numeric
+ * plots.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public class VerticalCategoryAxisBead extends AxisBaseBead implements IBead, IVerticalAxisBead
+ {
+ /**
+ * constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function VerticalCategoryAxisBead()
+ {
+ super();
+
+ placement = "left";
+ }
+
+ /**
+ * @copy org.apache.flex.core.IBead#strand
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ override public function set strand(value:IStrand):void
+ {
+ super.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 _categoryField:String;
+
+ /**
+ * The name of field within the chart data to used to categorize each of the
+ * axis data points.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function get categoryField():String
+ {
+ return _categoryField;
+ }
+ public function set categoryField(value:String):void
+ {
+ _categoryField = value;
+ }
+
+ private var _axisWidth:Number = 100;
+
+ /**
+ * The overall width of the axis.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function get axisWidth():Number
+ {
+ return _axisWidth;
+ }
+
+ public function set axisWidth(value:Number):void
+ {
+ _axisWidth = 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
+ */
+ 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;
+ var items:Array;
+ if (model.dataProvider is Array) items = model.dataProvider as Array;
+ else return;
+
+ var series:Array = IChart(strand).series;
+
+ var useHeight:Number = UIBase(axisGroup).height;
+ var useWidth:Number = UIBase(axisGroup).width;
+ var itemHeight:Number = (useHeight - gap*(items.length-1)) / items.length;
+ var xpos:Number = 0;
+ var ypos:Number = useHeight - itemHeight/2;
+
+ var numTicks:Number = items.length;
+ var tickSpacing:Number = itemHeight + gap;
+
+ for(var i:int=0; i < items.length; i++)
+ {
+ addTickLabel(items[i][categoryField], 0, ypos, 0, itemHeight);
+
+ // add a tick mark, too.
+ addTickMark(useWidth-6, ypos, 5, 0);
+
+ ypos -= tickSpacing;
+ }
+
+ // draw the axis and tick marks
+ drawAxisPath(useWidth-1, 0, 0, useHeight);
+ drawTickPath(useWidth-6, 0);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b21f62/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/VerticalLinearAxisBead.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/VerticalLinearAxisBead.as b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/VerticalLinearAxisBead.as
new file mode 100644
index 0000000..20546f4
--- /dev/null
+++ b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/VerticalLinearAxisBead.as
@@ -0,0 +1,226 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.IVerticalAxisBead;
+ import org.apache.flex.core.IBead;
+ 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.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 extends AxisBaseBead implements IBead, IVerticalAxisBead
+ {
+ public function VerticalLinearAxisBead()
+ {
+ super();
+
+ placement = "left";
+ }
+
+ /**
+ * @copy org.apache.flex.core.IBead#strand
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ override public function set strand(value:IStrand):void
+ {
+ super.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 minimum and maximum 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 _minimum:Number = 0;
+
+ /**
+ * The minimun value to be represented on this axis. If minimum 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 minimum():Number
+ {
+ return _minimum;
+ }
+ public function set minimum(value:Number):void
+ {
+ _minimum = value;
+ }
+
+ private var _maximum:Number = Number.NaN;
+
+ /**
+ * The maximum value to be represented on this axis. If maximum 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 maximum():Number
+ {
+ return _maximum;
+ }
+ public function set maximum(value:Number):void
+ {
+ _maximum = 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 model:ArraySelectionModel = strand.getBeadByType(ISelectionModel) as ArraySelectionModel;
+ var items:Array;
+ if (model.dataProvider is Array) items = model.dataProvider as Array;
+ else return;
+
+ var series:Array = IChart(strand).series;
+
+ var useHeight:Number = UIBase(axisGroup).height;
+ 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(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(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 = range/numTicks;
+ var tickSpacing:Number = useHeight/numTicks;
+ var tickValue:Number = minimum;
+
+ // place the labels below the axis enough to account for the tick marks
+ var labelY:Number = UIBase(axisGroup).height + 8;
+
+ for(i=0; i < numTicks+1; i++)
+ {
+ addTickLabel(formatLabel(tickValue), 0, ypos, 0, tickSpacing);
+
+ // add a tick mark, too.
+ addTickMark(useWidth-6, ypos, 5, 0);
+
+ ypos -= tickSpacing;
+ tickValue += tickStep;
+ }
+
+ // draw the axis and the tick marks
+ drawAxisPath(useWidth-1, 0, 0, useHeight);
+ drawTickPath(useWidth-6, 0);
+
+ }
+
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b21f62/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/BarChartLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/BarChartLayout.as b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/BarChartLayout.as
new file mode 100644
index 0000000..076fb0a
--- /dev/null
+++ b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/BarChartLayout.as
@@ -0,0 +1,149 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.layouts
+{
+ import org.apache.flex.charts.core.ICartesianChartLayout;
+ import org.apache.flex.charts.core.IChartItemRenderer;
+ import org.apache.flex.charts.core.IChartSeries;
+ import org.apache.flex.charts.supportClasses.BarSeries;
+ import org.apache.flex.core.IBeadLayout;
+ import org.apache.flex.core.ISelectionModel;
+ import org.apache.flex.core.UIBase;
+ import org.apache.flex.events.Event;
+ import org.apache.flex.events.IEventDispatcher;
+
+ /**
+ * The BarChartLayout class calculates the size and position of all of the itemRenderers for
+ * all of the series in a BarChart.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public class BarChartLayout extends ChartBaseLayout implements IBeadLayout, ICartesianChartLayout
+ {
+ /**
+ * constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function BarChartLayout()
+ {
+ super();
+ }
+
+ 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
+ */
+ override protected function performLayout():void
+ {
+ var selectionModel:ISelectionModel = chart.getBeadByType(ISelectionModel) as ISelectionModel;
+ var dp:Array = selectionModel.dataProvider as Array;
+ if (!dp)
+ return;
+
+ var n:int = dp.length;
+ var useWidth:Number = UIBase(chartDataGroup).width;
+ var useHeight:Number = UIBase(chartDataGroup).height;
+ var itemHeight:Number = (useHeight - gap*(dp.length-1))/dp.length;
+ var seriesHeight:Number = itemHeight/chart.series.length;
+ var ypos:Number = useHeight;
+
+ var maxXValue:Number = 0;
+ 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;
+
+ for (var i:int = 0; i < n; i++)
+ {
+ var data:Object = dp[i];
+ var field:String = bcs.xField;
+
+ var xValue:Number = Number(data[field]);
+ if (determineScale) maxXValue = Math.max(xValue, maxXValue);
+ }
+ }
+
+ var range:Number = maxXValue - minXValue;
+ scaleFactor = useWidth/range;
+
+ for (i = 0; i < n; i++)
+ {
+ data = dp[i];
+
+ for (s=0; s < chart.series.length; s++)
+ {
+ bcs = chart.series[s] as BarSeries;
+
+ var child:IChartItemRenderer = chartDataGroup.getItemRendererForSeriesAtIndex(bcs,i);
+ xValue = Number(data[bcs.xField]) - minXValue;
+ if (xValue > maxXValue) xValue = maxXValue;
+ xValue = xValue * scaleFactor;
+
+ child.x = 0;
+ child.y = ypos - seriesHeight;
+ child.width = xValue;
+ child.height = seriesHeight;
+ ypos -= seriesHeight;
+ }
+
+ ypos -= gap;
+ }
+
+ IEventDispatcher(chart).dispatchEvent(new Event("layoutComplete"));
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b21f62/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/ChartBaseLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/ChartBaseLayout.as b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/ChartBaseLayout.as
new file mode 100644
index 0000000..ef4e9b8
--- /dev/null
+++ b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/ChartBaseLayout.as
@@ -0,0 +1,146 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.layouts
+{
+ import org.apache.flex.charts.core.ChartBase;
+ import org.apache.flex.charts.core.IChartDataGroup;
+ import org.apache.flex.charts.core.IHorizontalAxisBead;
+ import org.apache.flex.charts.core.IVerticalAxisBead;
+ import org.apache.flex.core.IBeadLayout;
+ import org.apache.flex.core.ILayoutParent;
+ import org.apache.flex.core.IStrand;
+ import org.apache.flex.events.Event;
+ import org.apache.flex.events.IEventDispatcher;
+
+ public class ChartBaseLayout implements IBeadLayout
+ {
+ public function ChartBaseLayout()
+ {
+ }
+
+ 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;
+ IEventDispatcher(value).addEventListener("widthChanged", changeHandler);
+ IEventDispatcher(value).addEventListener("childrenAdded", changeHandler);
+ IEventDispatcher(value).addEventListener("itemsCreated", changeHandler);
+ IEventDispatcher(value).addEventListener("layoutNeeded", changeHandler);
+ }
+
+ /**
+ * Returns the strand, cast as an instance of ChartBase.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function get chart():ChartBase
+ {
+ return _strand as ChartBase;
+ }
+
+ private var _xAxis:IHorizontalAxisBead = null;
+
+ /**
+ * The horizontal axis bead or null if one is not present.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function get horizontalAxisBead():IHorizontalAxisBead
+ {
+ if (_xAxis == null) {
+ if (chart.getBeadByType(IHorizontalAxisBead)) _xAxis = chart.getBeadByType(IHorizontalAxisBead) as IHorizontalAxisBead;
+ }
+ return _xAxis;
+ }
+
+ private var _yAxis:IVerticalAxisBead = null;
+
+ /**
+ * The vertical axis bead or null if one is not present.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function get verticalAxisBead():IVerticalAxisBead
+ {
+ if (_yAxis == null) {
+ if (chart.getBeadByType(IVerticalAxisBead)) _yAxis = chart.getBeadByType(IVerticalAxisBead) as IVerticalAxisBead;
+ }
+ return _yAxis;
+ }
+
+ private var _chartDataGroup:IChartDataGroup;
+
+ /**
+ * Returns the object into which the chart elements are drawn or added. The ChartDataGroup implements
+ * IContentView.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function get chartDataGroup():IChartDataGroup
+ {
+ if (_chartDataGroup == null) {
+ var layoutParent:ILayoutParent = chart.getBeadByType(ILayoutParent) as ILayoutParent;
+ _chartDataGroup = layoutParent.contentView as IChartDataGroup;
+ }
+ return _chartDataGroup;
+ }
+
+ /**
+ * @private
+ */
+ private function changeHandler(event:Event):void
+ {
+ performLayout();
+ }
+
+ /**
+ * Subclasses should implement this to draw the chart, adding elements to the chartDataGroup.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ protected function performLayout():void
+ {
+ // implement in subclass
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b21f62/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/ColumnChartLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/ColumnChartLayout.as b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/ColumnChartLayout.as
new file mode 100644
index 0000000..0d8c019
--- /dev/null
+++ b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/ColumnChartLayout.as
@@ -0,0 +1,140 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.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;
+ import org.apache.flex.core.UIBase;
+ import org.apache.flex.events.Event;
+ import org.apache.flex.events.IEventDispatcher;
+
+ /**
+ * The ColumnChartLayout arranges the graphics in vertical columns (or whatever shape
+ * the renderer uses) using a category axis horizontally and a linear axis vertically.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public class ColumnChartLayout extends ChartBaseLayout implements IBeadLayout, ICartesianChartLayout
+ {
+ public function ColumnChartLayout()
+ {
+ }
+
+ 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
+ */
+ override protected function performLayout():void
+ {
+ var selectionModel:ISelectionModel = chart.getBeadByType(ISelectionModel) as ISelectionModel;
+ var dp:Array = selectionModel.dataProvider as Array;
+ if (!dp)
+ return;
+
+ var n:int = dp.length;
+ var xpos:Number = 0;
+ var useWidth:Number = UIBase(chartDataGroup).width;
+ var useHeight:Number = UIBase(chartDataGroup).height;
+ var itemWidth:Number = (useWidth - gap*(dp.length-1))/dp.length;
+ var seriesWidth:Number = itemWidth/chart.series.length;
+
+ var maxYValue:Number = 0;
+ 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;
+
+ for (var i:int = 0; i < n; i++)
+ {
+ var data:Object = dp[i];
+ var field:String = bcs.yField;
+
+ var yValue:Number = Number(data[field]);
+ if (determineScale) maxYValue = Math.max(yValue, maxYValue);
+ }
+ }
+
+ var range:Number = maxYValue - minYValue;
+ scaleFactor = useHeight/range;
+
+ for (i = 0; i < n; i++)
+ {
+ data = dp[i];
+
+ for (s=0; s < chart.series.length; s++)
+ {
+ bcs = chart.series[s] as ColumnSeries;
+
+ var child:IChartItemRenderer = chartDataGroup.getItemRendererForSeriesAtIndex(bcs,i);
+ yValue = Number(data[bcs.yField]) - minYValue;
+ if (yValue > maxYValue) yValue = maxYValue;
+ yValue = yValue * scaleFactor;
+
+ child.y = useHeight - yValue;
+ child.x = xpos;
+ child.width = seriesWidth;
+ child.height = yValue;
+ xpos += seriesWidth;
+ }
+
+ xpos += gap;
+ }
+
+ IEventDispatcher(chart).dispatchEvent(new Event("layoutComplete"));
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b21f62/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/LineChartCategoryVsLinearLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/LineChartCategoryVsLinearLayout.as b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/LineChartCategoryVsLinearLayout.as
new file mode 100644
index 0000000..8a15003
--- /dev/null
+++ b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/LineChartCategoryVsLinearLayout.as
@@ -0,0 +1,147 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.layouts
+{
+ import org.apache.flex.charts.core.ICartesianChartLayout;
+ import org.apache.flex.charts.core.IChartItemRenderer;
+ import org.apache.flex.charts.core.IChartSeries;
+ import org.apache.flex.charts.supportClasses.ILineSegmentItemRenderer;
+ import org.apache.flex.charts.supportClasses.LineSeries;
+ import org.apache.flex.core.IBeadLayout;
+ import org.apache.flex.core.ISelectionModel;
+ import org.apache.flex.core.UIBase;
+ import org.apache.flex.events.Event;
+ import org.apache.flex.events.IEventDispatcher;
+
+ /**
+ * The LineChartCategoryVsLinearLayout displays a line graph of plot points
+ * where the horizontal axis is category value and the vertical axis is numeric.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public class LineChartCategoryVsLinearLayout extends ChartBaseLayout implements IBeadLayout, ICartesianChartLayout
+ {
+ public function LineChartCategoryVsLinearLayout()
+ {
+ }
+
+ /**
+ * @private
+ */
+ override protected function performLayout():void
+ {
+ var selectionModel:ISelectionModel = chart.getBeadByType(ISelectionModel) as ISelectionModel;
+ var dp:Array = selectionModel.dataProvider as Array;
+ if (!dp)
+ return;
+
+ var n:int = dp.length;
+ var xAxisOffset:Number = 0;
+ var yAxisOffset:Number = 0;
+
+ var xpos:Number = yAxisOffset;
+ var useWidth:Number = UIBase(chartDataGroup).width-yAxisOffset;;
+ var useHeight:Number = UIBase(chartDataGroup).height - xAxisOffset;
+ var itemWidth:Number = useWidth/dp.length;
+
+ var maxYValue:Number = 0;
+ 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;
+ seriesPoints.push({points:[]});
+
+ for (var i:int = 0; i < n; i++)
+ {
+ var data:Object = dp[i];
+ var field:String = aseries.yField;
+
+ var yValue:Number = Number(data[field]);
+ 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.
+
+ for (s=0; s < chart.series.length; s++)
+ {
+ aseries = chart.series[s] as IChartSeries;
+
+ xpos = yAxisOffset + itemWidth/2;
+
+ for (i=0; i < n; i++)
+ {
+ data = dp[i];
+ yValue = Number(data[aseries.yField]) - minYValue;
+
+ var childX:Number = xpos;
+ var childY:Number = useHeight - yValue*scaleYFactor;
+
+ seriesPoints[s].points.push( {x:childX, y:childY} );
+
+ var child:IChartItemRenderer = chartDataGroup.getItemRendererForSeriesAtIndex(aseries,i);
+ if (child) {
+ child.x = childX - 5;
+ child.y = childY - 5;
+ child.width = 10;
+ child.height = 10;
+ }
+
+ xpos += itemWidth;
+ }
+ }
+
+ // draw the line segment
+
+ for (s=0; s < chart.series.length; s++)
+ {
+ var lcs:LineSeries = chart.series[s] as LineSeries;
+
+ if (lcs.lineSegmentRenderer)
+ {
+ var renderer:ILineSegmentItemRenderer = lcs.lineSegmentRenderer.newInstance() as ILineSegmentItemRenderer;
+ chartDataGroup.addElement(renderer);
+ renderer.itemRendererParent = chartDataGroup;
+ renderer.data = lcs;
+ renderer.points = seriesPoints[s].points;
+ }
+ }
+
+ IEventDispatcher(chart).dispatchEvent(new Event("layoutComplete"));
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b21f62/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/LineChartLinearVsLinearLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/LineChartLinearVsLinearLayout.as b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/LineChartLinearVsLinearLayout.as
new file mode 100644
index 0000000..6719aa0
--- /dev/null
+++ b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/LineChartLinearVsLinearLayout.as
@@ -0,0 +1,161 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.layouts
+{
+ import org.apache.flex.charts.core.ICartesianChartLayout;
+ import org.apache.flex.charts.core.IChartItemRenderer;
+ import org.apache.flex.charts.core.IChartSeries;
+ import org.apache.flex.charts.supportClasses.ILineSegmentItemRenderer;
+ import org.apache.flex.charts.supportClasses.LineSeries;
+ import org.apache.flex.core.IBeadLayout;
+ import org.apache.flex.core.ISelectionModel;
+ import org.apache.flex.core.UIBase;
+ import org.apache.flex.events.Event;
+ import org.apache.flex.events.IEventDispatcher;
+
+ /**
+ * The LineChartLinearVsLinearLayout displays a line graph of plot points
+ * where both axes are numeric values.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public class LineChartLinearVsLinearLayout extends ChartBaseLayout implements IBeadLayout, ICartesianChartLayout
+ {
+ public function LineChartLinearVsLinearLayout()
+ {
+ }
+
+ /**
+ * @private
+ */
+ override protected function performLayout():void
+ {
+ var selectionModel:ISelectionModel = chart.getBeadByType(ISelectionModel) as ISelectionModel;
+ var dp:Array = selectionModel.dataProvider as Array;
+ if (!dp)
+ return;
+
+ var n:int = dp.length;
+
+ 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 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;
+ seriesPoints.push({points:[]});
+
+ for (var i:int = 0; i < n; i++)
+ {
+ var data:Object = dp[i];
+ var xfield:String = aseries.xField;
+ var yfield:String = aseries.yField;
+
+ var xValue:Number = Number(data[xfield]);
+ if (determineXScale) maxXValue = Math.max(maxXValue, xValue);
+
+ var yValue:Number = Number(data[yfield]);
+ if (determineYScale) maxYValue = Math.max(maxYValue, yValue);
+ }
+ }
+
+ scaleXFactor = useWidth / (maxXValue - minXValue);
+ scaleYFactor = useHeight / (maxYValue - minYValue);
+
+ // draw the itemRenderers at each vertex and build the points array for the
+ // line segment.
+
+ for (s=0; s < chart.series.length; s++)
+ {
+ aseries = chart.series[s] as IChartSeries;
+
+ for (i=0; i < n; i++)
+ {
+ data = dp[i];
+ xValue = Number(data[aseries.xField]) - minXValue;
+ yValue = Number(data[aseries.yField]) - minYValue;
+
+ var childX:Number = (xValue*scaleXFactor);
+ var childY:Number = useHeight - (yValue*scaleYFactor);
+
+ seriesPoints[s].points.push( {x:childX, y:childY} );
+
+ var child:IChartItemRenderer = chartDataGroup.getItemRendererForSeriesAtIndex(aseries,i);
+ if (child) {
+ child.x = childX - 5;
+ child.y = childY - 5;
+ child.width = 10;
+ child.height = 10;
+ }
+ }
+ }
+
+ // draw the line segment
+
+ for (s=0; s < chart.series.length; s++)
+ {
+ var lcs:LineSeries = chart.series[s] as LineSeries;
+
+ if (lcs.lineSegmentRenderer)
+ {
+ var renderer:ILineSegmentItemRenderer = lcs.lineSegmentRenderer.newInstance() as ILineSegmentItemRenderer;
+ chartDataGroup.addElement(renderer);
+ renderer.itemRendererParent = chartDataGroup;
+ renderer.data = lcs;
+ renderer.points = seriesPoints[s].points;
+ }
+ }
+
+ IEventDispatcher(chart).dispatchEvent(new Event("layoutComplete"));
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b21f62/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/PieChartLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/PieChartLayout.as b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/PieChartLayout.as
new file mode 100644
index 0000000..40bdcf4
--- /dev/null
+++ b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/PieChartLayout.as
@@ -0,0 +1,135 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.layouts
+{
+ import org.apache.flex.charts.core.IChartItemRenderer;
+ import org.apache.flex.charts.core.IChartSeries;
+ import org.apache.flex.charts.supportClasses.IWedgeItemRenderer;
+ import org.apache.flex.charts.supportClasses.PieSeries;
+ import org.apache.flex.core.IBeadLayout;
+ import org.apache.flex.core.ISelectionModel;
+ import org.apache.flex.core.graphics.IFill;
+ import org.apache.flex.core.graphics.SolidColor;
+ import org.apache.flex.events.Event;
+ import org.apache.flex.events.IEventDispatcher;
+
+ /**
+ * The PieChartLayout class calculates the size and position of all of the itemRenderers for
+ * a PieChart.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public class PieChartLayout extends ChartBaseLayout implements IBeadLayout
+ {
+ /**
+ * constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function PieChartLayout()
+ {
+ }
+
+ /**
+ * @private
+ */
+ override protected function performLayout():void
+ {
+ var selectionModel:ISelectionModel = chart.getBeadByType(ISelectionModel) as ISelectionModel;
+ var dp:Array = selectionModel.dataProvider as Array;
+ if (!dp)
+ return;
+
+ var n:int = dp.length;
+
+ var xpos:Number = 0;
+ var useWidth:Number = chart.width;
+ var useHeight:Number = chart.height;
+
+ var maxYValue:Number = 0;
+ var seriesMaxes:Array = [];
+ var colors:Array = [0xFF964D, 0x964DFF, 0xF80012, 0x96FF4D, 0x4D96FF, 0x8A8A01, 0x23009C, 0x4A4A4A, 0x23579D];
+
+ for (var s:int = 0; s < chart.series.length; s++)
+ {
+ var pcs:PieSeries = chart.series[s] as PieSeries;
+
+ for (var i:int = 0; i < n; i++)
+ {
+ var data:Object = dp[i];
+ var field:String = pcs.dataField;
+
+ var yValue:Number = Number(data[field]);
+ maxYValue += yValue;
+
+ seriesMaxes.push( {yValue:yValue, percent:0, arc:0} );
+ }
+
+ for (i=0; i < n; i++)
+ {
+ var obj:Object = seriesMaxes[i];
+ obj.percent = obj.yValue / maxYValue;
+ obj.arc = 360.0*obj.percent;
+ }
+
+ var start:Number = 0;
+ var end:Number = 0;
+ var radius:Number = Math.min(useWidth,useHeight)/2;
+ var centerX:Number = useWidth/2;
+ var centerY:Number = useHeight/2;
+
+ for (i=0; i < n; i++)
+ {
+ obj = seriesMaxes[i];
+ data = dp[i];
+
+ var fill:SolidColor = new SolidColor();
+ fill.color = colors[i%colors.length];
+ fill.alpha = 1.0;
+
+ var child:IWedgeItemRenderer = chartDataGroup.getItemRendererForSeriesAtIndex(chart.series[s],i) as IWedgeItemRenderer;
+ child.fill = fill;
+
+ end = start + (360.0 * obj.percent);
+ var arc:Number = 360.0 * obj.percent;
+
+ child.x = 0;
+ child.y = 0;
+ child.width = useWidth;
+ child.height = useHeight;
+ child.centerX = centerX;
+ child.centerY = centerY;
+ child.startAngle = start*Math.PI/180;
+ child.arc = arc*Math.PI/180;
+ child.radius = radius;
+
+ start += arc;
+ }
+ }
+
+ IEventDispatcher(chart).dispatchEvent(new Event("layoutComplete"));
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b21f62/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/StackedBarChartLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/StackedBarChartLayout.as b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/StackedBarChartLayout.as
new file mode 100644
index 0000000..07bb720
--- /dev/null
+++ b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/StackedBarChartLayout.as
@@ -0,0 +1,159 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.layouts
+{
+ import org.apache.flex.charts.core.ICartesianChartLayout;
+ import org.apache.flex.charts.core.IChartItemRenderer;
+ import org.apache.flex.charts.core.IChartSeries;
+ import org.apache.flex.charts.supportClasses.BarSeries;
+ import org.apache.flex.core.IBeadLayout;
+ import org.apache.flex.core.ISelectionModel;
+ import org.apache.flex.core.UIBase;
+ import org.apache.flex.events.Event;
+ import org.apache.flex.events.IEventDispatcher;
+
+ /**
+ * The StackedBarChartLayout class calculates the size and position of all of the itemRenderers for
+ * all of the series in a StackedBarChart.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public class StackedBarChartLayout extends ChartBaseLayout implements IBeadLayout, ICartesianChartLayout
+ {
+ /**
+ * constructor
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function StackedBarChartLayout()
+ {
+ }
+
+ 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
+ */
+ override protected function performLayout():void
+ {
+ var selectionModel:ISelectionModel = chart.getBeadByType(ISelectionModel) as ISelectionModel;
+ var dp:Array = selectionModel.dataProvider as Array;
+ if (!dp)
+ return;
+
+ 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;
+ var useHeight:Number = UIBase(chartDataGroup).height;
+ var itemHeight:Number = (useHeight - gap*(dp.length-1))/n;
+ var seriesHeight:Number = itemHeight;
+ var xpos:Number = 0;
+ var ypos:Number = useHeight;
+
+ var barValues:Array = [];
+ 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});
+
+ var data:Object = dp[i];
+
+ for (var s:int = 0; s < chart.series.length; s++)
+ {
+ var bcs:BarSeries = chart.series[s] as BarSeries;
+ var field:String = bcs.xField;
+
+ var xValue:Number = Number(data[field]);
+ barValues[i].totalValue += xValue;
+ }
+
+ if (determineScale) {
+ maxXValue = Math.max(maxXValue, barValues[i].totalValue);
+ }
+ }
+
+ scaleFactor = useWidth/(maxXValue - minXValue);
+
+ for (i=0; i < n; i++)
+ {
+ data = dp[i];
+
+ xpos = 0;
+
+ for (s=0; s < chart.series.length; s++)
+ {
+ bcs = chart.series[s] as BarSeries;
+
+ var child:IChartItemRenderer = chartDataGroup.getItemRendererForSeriesAtIndex(bcs,i);
+ xValue = Number(data[bcs.xField]) - minXValue;
+ xValue = xValue * scaleFactor;
+
+ child.x = xpos;
+ child.width = Math.floor(xValue);
+ child.y = Math.floor(ypos - seriesHeight);
+ child.height = seriesHeight;
+
+ xpos += xValue;
+ }
+
+ ypos -= (itemHeight + gap);
+ }
+
+ IEventDispatcher(chart).dispatchEvent(new Event("layoutComplete"));
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b21f62/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/StackedColumnChartLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/StackedColumnChartLayout.as b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/StackedColumnChartLayout.as
new file mode 100644
index 0000000..074f82d
--- /dev/null
+++ b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/beads/layouts/StackedColumnChartLayout.as
@@ -0,0 +1,156 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.layouts
+{
+ import org.apache.flex.charts.core.ICartesianChartLayout;
+ import org.apache.flex.charts.core.IChartItemRenderer;
+ import org.apache.flex.charts.supportClasses.ColumnSeries;
+ import org.apache.flex.core.IBeadLayout;
+ import org.apache.flex.core.ISelectionModel;
+ import org.apache.flex.core.UIBase;
+ import org.apache.flex.events.Event;
+ import org.apache.flex.events.IEventDispatcher;
+
+ /**
+ * The StackedColumnChartLayout class calculates the size and position of all of the itemRenderers for
+ * all of the series in a StackedColumnChart.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public class StackedColumnChartLayout extends ChartBaseLayout implements IBeadLayout, ICartesianChartLayout
+ {
+ /**
+ * constructor
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function StackedColumnChartLayout()
+ {
+ }
+
+ 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
+ */
+ override protected function performLayout():void
+ {
+ var selectionModel:ISelectionModel = chart.getBeadByType(ISelectionModel) as ISelectionModel;
+ var dp:Array = selectionModel.dataProvider as Array;
+ if (!dp)
+ return;
+
+ var n:int = dp.length;
+ var useWidth:Number = UIBase(chartDataGroup).width;
+ var useHeight:Number = UIBase(chartDataGroup).height;
+ var itemWidth:Number = (useWidth - gap*(dp.length-1))/dp.length;
+ var seriesWidth:Number = itemWidth;
+ var xpos:Number = 0;
+ var ypos:Number = 0;
+
+ var maxYValue:Number = 0;
+ var minYValue:Number = 0;
+ var determineScale:Boolean = true;
+
+ var barValues:Array = [];
+ 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});
+ var data:Object = dp[i];
+
+ for (var s:int = 0; s < chart.series.length; s++)
+ {
+ var bcs:ColumnSeries = chart.series[s] as ColumnSeries;
+ var field:String = bcs.yField;
+
+ var yValue:Number = Number(data[field]);
+ barValues[i].totalValue += yValue;
+ }
+
+ if (determineScale) {
+ maxYValue = Math.max(maxYValue, barValues[i].totalValue);
+ }
+ }
+
+ scaleFactor = useHeight / (maxYValue - minYValue);
+
+ for (i=0; i < n; i++)
+ {
+ data = dp[i];
+ ypos = useHeight;
+
+ for (s=0; s < chart.series.length; s++)
+ {
+ bcs = chart.series[s] as ColumnSeries;
+
+ var child:IChartItemRenderer = chartDataGroup.getItemRendererForSeriesAtIndex(bcs,i);
+
+ yValue = Number(data[field]) - minYValue;
+ yValue = yValue * scaleFactor;
+
+ child.x = xpos;
+ child.width = itemWidth;
+ child.y = ypos - Math.ceil(yValue);
+ child.height = Math.floor(yValue);
+
+ ypos = child.y;
+ }
+
+ xpos += gap + itemWidth;
+ }
+
+ IEventDispatcher(chart).dispatchEvent(new Event("layoutComplete"));
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b21f62/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/optimized/SVGBoxItemRenderer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/optimized/SVGBoxItemRenderer.as b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/optimized/SVGBoxItemRenderer.as
new file mode 100644
index 0000000..8b7055c
--- /dev/null
+++ b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/optimized/SVGBoxItemRenderer.as
@@ -0,0 +1,166 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.optimized
+{
+ import org.apache.flex.charts.core.IChartItemRenderer;
+ import org.apache.flex.charts.core.IChartSeries;
+ import org.apache.flex.core.graphics.GraphicsContainer;
+ import org.apache.flex.core.graphics.IFill;
+ import org.apache.flex.core.graphics.IStroke;
+ import org.apache.flex.core.graphics.SolidColor;
+ import org.apache.flex.core.graphics.SolidColorStroke;
+ import org.apache.flex.html.supportClasses.DataItemRenderer;
+ import org.apache.flex.html.supportClasses.GraphicsItemRenderer;
+
+ /**
+ * The SVGBoxItemRenderer draws its graphics directly into a SVGChartDataGroup
+ * (GraphicsContainer).
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public class SVGBoxItemRenderer extends GraphicsItemRenderer implements IChartItemRenderer
+ {
+ /**
+ * constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function SVGBoxItemRenderer()
+ {
+ super();
+ }
+
+ private var _series:IChartSeries;
+
+ /**
+ * The series to which this itemRenderer instance belongs. Or, the series
+ * being presented.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function get series():IChartSeries
+ {
+ return _series;
+ }
+ public function set series(value:IChartSeries):void
+ {
+ _series = value;
+ }
+
+ private var _yField:String = "y";
+
+ /**
+ * The name of the field containing the value for the Y axis.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function get yField():String
+ {
+ return _yField;
+ }
+ public function set yField(value:String):void
+ {
+ _yField = value;
+ }
+
+ private var _xField:String = "x";
+
+ /**
+ * The name of the field containing the value for the X axis.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function get xField():String
+ {
+ return _xField;
+ }
+ public function set xField(value:String):void
+ {
+ _xField = value;
+ }
+
+ /**
+ * @copy org.apache.flex.supportClasses.UIItemRendererBase#data
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ override public function set data(value:Object):void
+ {
+ super.data = value;
+ drawBar();
+ }
+
+ /**
+ * @copy org.apache.flex.core.UIBase#width
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ override public function set width(value:Number):void
+ {
+ super.width = value;
+ drawBar();
+ }
+
+ /**
+ * @copy org.apache.flex.core.UIBase#height
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ override public function set height(value:Number):void
+ {
+ super.height = value;
+ drawBar();
+ }
+
+ /**
+ * @private
+ */
+ protected function drawBar():void
+ {
+ if ((this.width > 0) && (this.height > 0))
+ {
+ this.drawRect(0, 0, this.width, this.height);
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/72b21f62/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/optimized/SVGChartAxisGroup.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/optimized/SVGChartAxisGroup.as b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/optimized/SVGChartAxisGroup.as
new file mode 100644
index 0000000..479d85f
--- /dev/null
+++ b/frameworks/projects/Charts/asjs/src/org/apache/flex/charts/optimized/SVGChartAxisGroup.as
@@ -0,0 +1,142 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.optimized
+{
+ import org.apache.flex.charts.core.IAxisGroup;
+ import org.apache.flex.core.graphics.GraphicsContainer;
+ import org.apache.flex.core.graphics.IFill;
+ import org.apache.flex.core.graphics.IStroke;
+
+ /**
+ * The SVGChartAxisGroup provides a GraphicsContainer whose drawing functions
+ * can be used to display a chart's axis graphics without resorting to the
+ * creation of extra objects.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public class SVGChartAxisGroup extends GraphicsContainer implements IAxisGroup
+ {
+ /**
+ * Constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function SVGChartAxisGroup()
+ {
+ super();
+ }
+
+ /**
+ * @private
+ */
+ override public function addedToParent():void
+ {
+ super.addedToParent();
+ }
+
+ /**
+ * Draws a horizontal tick label centered in the box at the given position.
+ *
+ * @param text The label to display.
+ * @param xpos The x position of the label's upper left corner.
+ * @param ypos The y position of the label's upper left corner.
+ * @param boxWith The size of the box into which the label should be drawn.
+ * @param boxHeight The size of the box into which the label should be drawn.
+ * @param tickFill A fill to use to display the label.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function drawHorizontalTickLabel( text:String, xpos:Number, ypos:Number, boxWidth:Number, boxHeight:Number, tickFill:IFill ):void
+ {
+ fill = tickFill;
+ drawText(text, xpos-boxWidth/2, ypos);
+ }
+
+ /**
+ * Draws a vertical tick label centered in the box at the given position.
+ *
+ * @param text The label to display.
+ * @param xpos The x position of the label's upper left corner.
+ * @param ypos The y position of the label's upper left corner.
+ * @param boxWith The size of the box into which the label should be drawn.
+ * @param boxHeight The size of the box into which the label should be drawn.
+ * @param tickFill A fill to use to display the label.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function drawVerticalTickLabel( text:String, xpos:Number, ypos:Number, boxWidth:Number, boxHeight:Number, tickFill:IFill ):void
+ {
+ fill = tickFill;
+ drawText(text, xpos, ypos-boxHeight/4);
+ }
+
+ /**
+ * Draws an set of tick marks are determined in the marks path.
+ *
+ * @param originX The upper left corner of the space into which the tick marks are drawn.
+ * @param originY The upper left corner of the space into which the tick marks are drawn.
+ * @param width The size of the box into which the tick marks are drawn.
+ * @param height The size of the box into which the tick marks are drawn.
+ * @param tickStroke The stroke to use to display the tick marks.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function drawTickMarks( originX:Number, originY:Number, width:Number, height:Number, marks:String, tickStroke:IStroke ):void
+ {
+ stroke = tickStroke;
+ drawPath(marks);
+ }
+
+ /**
+ * Draws the axis line at the given position.
+ *
+ * @param originX The upper left corner of the space into which the axis line is drawn.
+ * @param originY The upper left corner of the space into which the axis line is drawn.
+ * @param width The size of the box into which the line is drawn.
+ * @param height The size of the box into which the line is drawn.
+ * @param lineStroke The stroke to use to display the line.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function drawAxisLine( originX:Number, originY:Number, width:Number, height:Number, lineStroke:IStroke ):void
+ {
+ stroke = lineStroke;
+ var pathLine:String = "M " + String(originX) + " " + String(originY) + " l "+String(width)+" "+String(height);
+ drawPath(pathLine);
+ }
+ }
+}
\ No newline at end of file