You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by pe...@apache.org on 2014/08/25 21:44:50 UTC
git commit: [flex-asjs] [refs/heads/develop] - Renamed "StackedChart"
to "StackedColumnChart" and created StackedBarChart.
Repository: flex-asjs
Updated Branches:
refs/heads/develop 6168f83f9 -> 86916b5eb
Renamed "StackedChart" to "StackedColumnChart" and created StackedBarChart.
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/86916b5e
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/86916b5e
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/86916b5e
Branch: refs/heads/develop
Commit: 86916b5ebddce3bd4aa26bc5c6413535421dab96
Parents: 6168f83
Author: Peter Ent <pe...@apache.org>
Authored: Mon Aug 25 15:44:45 2014 -0400
Committer: Peter Ent <pe...@apache.org>
Committed: Mon Aug 25 15:44:45 2014 -0400
----------------------------------------------------------------------
.../as/projects/FlexJSJX/basic-manifest.xml | 3 +-
frameworks/as/projects/FlexJSJX/defaults.css | 16 +-
.../as/projects/FlexJSJX/src/FlexJSJXClasses.as | 3 +-
.../org/apache/flex/charts/StackedBarChart.as | 48 +++++
.../src/org/apache/flex/charts/StackedChart.as | 48 -----
.../apache/flex/charts/StackedColumnChart.as | 48 +++++
.../beads/layouts/StackedBarChartLayout.as | 175 +++++++++++++++++++
.../charts/beads/layouts/StackedChartLayout.as | 173 ------------------
.../beads/layouts/StackedColumnChartLayout.as | 173 ++++++++++++++++++
9 files changed, 462 insertions(+), 225 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/86916b5e/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 2e8f113..b911e60 100644
--- a/frameworks/as/projects/FlexJSJX/basic-manifest.xml
+++ b/frameworks/as/projects/FlexJSJX/basic-manifest.xml
@@ -35,7 +35,8 @@
<component id="ColumnChart" class="org.apache.flex.charts.ColumnChart" />
<component id="PieChart" class="org.apache.flex.charts.PieChart" />
<component id="PieChartSeries" class="org.apache.flex.charts.supportClasses.PieChartSeries" />
- <component id="StackedChart" class="org.apache.flex.charts.StackedChart" />
+ <component id="StackedColumnChart" class="org.apache.flex.charts.StackedColumnChart" />
+ <component id="StackedBarChart" class="org.apache.flex.charts.StackedBarChart" />
<component id="XAxisBead" class="org.apache.flex.charts.beads.XAxisBead" />
<component id="YAxisBead" class="org.apache.flex.charts.beads.YAxisBead" />
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/86916b5e/frameworks/as/projects/FlexJSJX/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSJX/defaults.css b/frameworks/as/projects/FlexJSJX/defaults.css
index c847182..87d064c 100644
--- a/frameworks/as/projects/FlexJSJX/defaults.css
+++ b/frameworks/as/projects/FlexJSJX/defaults.css
@@ -82,12 +82,24 @@ PieChart
IItemRenderer: ClassReference("org.apache.flex.charts.supportClasses.WedgeItemRenderer");
}
-StackedChart
+StackedColumnChart
{
IBeadModel: ClassReference("org.apache.flex.html.beads.models.ArraySelectionModel");
IBeadView: ClassReference("org.apache.flex.html.beads.ListView");
IBeadController: ClassReference("org.apache.flex.html.beads.controllers.ListSingleSelectionMouseController");
- IBeadLayout: ClassReference("org.apache.flex.charts.beads.layouts.StackedChartLayout");
+ IBeadLayout: ClassReference("org.apache.flex.charts.beads.layouts.StackedColumnChartLayout");
+ IDataGroup: ClassReference("org.apache.flex.charts.ChartDataGroup");
+ IDataProviderItemRendererMapper: ClassReference("org.apache.flex.charts.beads.ChartItemRendererFactory");
+ IItemRendererClassFactory: ClassReference("org.apache.flex.core.ItemRendererClassFactory");
+ IItemRenderer: ClassReference("org.apache.flex.charts.supportClasses.BoxItemRenderer");
+}
+
+StackedBarChart
+{
+ IBeadModel: ClassReference("org.apache.flex.html.beads.models.ArraySelectionModel");
+ IBeadView: ClassReference("org.apache.flex.html.beads.ListView");
+ IBeadController: ClassReference("org.apache.flex.html.beads.controllers.ListSingleSelectionMouseController");
+ IBeadLayout: ClassReference("org.apache.flex.charts.beads.layouts.StackedBarChartLayout");
IDataGroup: ClassReference("org.apache.flex.charts.ChartDataGroup");
IDataProviderItemRendererMapper: ClassReference("org.apache.flex.charts.beads.ChartItemRendererFactory");
IItemRendererClassFactory: ClassReference("org.apache.flex.core.ItemRendererClassFactory");
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/86916b5e/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 7c964c1..4fc206b 100644
--- a/frameworks/as/projects/FlexJSJX/src/FlexJSJXClasses.as
+++ b/frameworks/as/projects/FlexJSJX/src/FlexJSJXClasses.as
@@ -35,7 +35,8 @@ internal class FlexJSJXClasses
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;
- import org.apache.flex.charts.beads.layouts.StackedChartLayout; StackedChartLayout;
+ import org.apache.flex.charts.beads.layouts.StackedBarChartLayout; StackedBarChartLayout;
+ import org.apache.flex.charts.beads.layouts.StackedColumnChartLayout; StackedColumnChartLayout;
import org.apache.flex.charts.supportClasses.BarChartSeries; BarChartSeries;
import org.apache.flex.charts.supportClasses.PieChartSeries; PieChartSeries;
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/86916b5e/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/StackedBarChart.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/StackedBarChart.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/StackedBarChart.as
new file mode 100644
index 0000000..415b176
--- /dev/null
+++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/StackedBarChart.as
@@ -0,0 +1,48 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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
+{
+ import org.apache.flex.charts.core.ChartBase;
+ import org.apache.flex.charts.core.IChart;
+
+ /**
+ * The StackedBarChart displays a histogram chart where each series in
+ * the chart is stack next to each other.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public class StackedBarChart extends ChartBase implements IChart
+ {
+ /**
+ * constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function StackedBarChart()
+ {
+ super();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/86916b5e/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/StackedChart.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/StackedChart.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/StackedChart.as
deleted file mode 100644
index 74f0f5c..0000000
--- a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/StackedChart.as
+++ /dev/null
@@ -1,48 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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
-{
- import org.apache.flex.charts.core.ChartBase;
- import org.apache.flex.charts.core.IChart;
-
- /**
- * The StackedChart displays a histogram chart where each series in
- * the chart is stack on top of each other.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public class StackedChart extends ChartBase implements IChart
- {
- /**
- * constructor.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public function StackedChart()
- {
- super();
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/86916b5e/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/StackedColumnChart.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/StackedColumnChart.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/StackedColumnChart.as
new file mode 100644
index 0000000..ab9ae2d
--- /dev/null
+++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/StackedColumnChart.as
@@ -0,0 +1,48 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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
+{
+ import org.apache.flex.charts.core.ChartBase;
+ import org.apache.flex.charts.core.IChart;
+
+ /**
+ * The StackedColumnChart displays a histogram chart where each series in
+ * the chart is stack on top of each other.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public class StackedColumnChart extends ChartBase implements IChart
+ {
+ /**
+ * constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function StackedColumnChart()
+ {
+ super();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/86916b5e/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
new file mode 100644
index 0000000..9b17e5d
--- /dev/null
+++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/StackedBarChartLayout.as
@@ -0,0 +1,175 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.beads.ChartItemRendererFactory;
+ import org.apache.flex.charts.core.ICartesianChartLayout;
+ import org.apache.flex.charts.core.IChart;
+ import org.apache.flex.charts.core.IChartItemRenderer;
+ import org.apache.flex.charts.core.IHorizontalAxisBead;
+ import org.apache.flex.charts.core.IVerticalAxisBead;
+ import org.apache.flex.charts.supportClasses.BarChartSeries;
+ import org.apache.flex.core.IBeadLayout;
+ import org.apache.flex.core.IDataProviderItemRendererMapper;
+ import org.apache.flex.core.ILayoutParent;
+ import org.apache.flex.core.IStrand;
+ 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 implements IBeadLayout, ICartesianChartLayout
+ {
+ /**
+ * constructor
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function StackedBarChartLayout()
+ {
+ }
+
+ 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);
+ }
+
+ 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 changeHandler(event:Event):void
+ {
+ var layoutParent:ILayoutParent = _strand.getBeadByType(ILayoutParent) as ILayoutParent;
+
+ var factory:ChartItemRendererFactory = _strand.getBeadByType(IDataProviderItemRendererMapper) as ChartItemRendererFactory;
+ var n:int = factory.seriesRenderers.length;
+
+ var maxXValue:Number = 0;
+ var series:Array = IChart(_strand).series;
+ trace("There are "+series.length+" series in this chart");
+ var seriesMaxes:Array = [];
+
+ var xAxis:IHorizontalAxisBead;
+ if (_strand.getBeadByType(IHorizontalAxisBead)) xAxis = _strand.getBeadByType(IHorizontalAxisBead) as IHorizontalAxisBead;
+ var xAxisOffset:Number = xAxis == null ? 0 : xAxis.axisHeight;
+ var yAxis:IVerticalAxisBead;
+ if (_strand.getBeadByType(IVerticalAxisBead)) yAxis = _strand.getBeadByType(IVerticalAxisBead) as IVerticalAxisBead;
+ 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 seriesHeight:Number = useHeight;
+ var xpos:Number = xAxisOffset;
+ var ypos:Number = UIBase(_strand).height - xAxisOffset - seriesHeight;
+
+ var barValues:Array = [];
+ var maxValue:Number = 0;
+ var scaleFactor:Number = 1;
+
+ for (var i:int=0; i < n; i++)
+ {
+ barValues.push({totalValue:0, scaleFactor:0});
+
+ for (var s:int = 0; s < series.length; s++)
+ {
+ var bcs:BarChartSeries = series[s] as BarChartSeries;
+ var m:Array = factory.seriesRenderers[i] as Array;
+ var item:IChartItemRenderer = m[s] as IChartItemRenderer;
+ var data:Object = item.data;
+ var field:String = bcs.yField;
+
+ var yValue:Number = Number(data[field]);
+ barValues[i].totalValue += yValue;
+ }
+
+ maxValue = Math.max(maxValue, barValues[i].totalValue);
+ }
+
+ scaleFactor = useWidth/maxValue;
+
+ for (i=0; i < n; i++)
+ {
+ m = factory.seriesRenderers[i] as Array;
+ xpos = yAxisOffset;
+ for (s=0; s < m.length; s++)
+ {
+ var child:IChartItemRenderer = m[s] as IChartItemRenderer;
+ data = child.data
+ yValue = Number(data[child.yField]);
+
+ child.x = xpos;
+ child.width = yValue*scaleFactor;
+ child.y = ypos;
+ child.height = seriesHeight;
+
+ xpos += yValue*scaleFactor;
+ }
+
+ ypos -= gap + seriesHeight;
+ }
+
+ IEventDispatcher(_strand).dispatchEvent(new Event("layoutComplete"));
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/86916b5e/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/StackedChartLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/StackedChartLayout.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/StackedChartLayout.as
deleted file mode 100644
index 915e61b..0000000
--- a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/StackedChartLayout.as
+++ /dev/null
@@ -1,173 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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.beads.ChartItemRendererFactory;
- import org.apache.flex.charts.core.ICartesianChartLayout;
- import org.apache.flex.charts.core.IChart;
- import org.apache.flex.charts.core.IChartItemRenderer;
- import org.apache.flex.charts.core.IHorizontalAxisBead;
- import org.apache.flex.charts.core.IVerticalAxisBead;
- import org.apache.flex.charts.supportClasses.BarChartSeries;
- import org.apache.flex.core.IBeadLayout;
- import org.apache.flex.core.IDataProviderItemRendererMapper;
- import org.apache.flex.core.ILayoutParent;
- import org.apache.flex.core.IStrand;
- import org.apache.flex.core.UIBase;
- import org.apache.flex.events.Event;
- import org.apache.flex.events.IEventDispatcher;
-
- /**
- * The StackChartLayout class calculates the size and position of all of the itemRenderers for
- * all of the series in a StackedChart.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public class StackedChartLayout implements IBeadLayout, ICartesianChartLayout
- {
- /**
- * constructor
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public function StackedChartLayout()
- {
- }
-
- 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);
- }
-
- 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 changeHandler(event:Event):void
- {
- var layoutParent:ILayoutParent = _strand.getBeadByType(ILayoutParent) as ILayoutParent;
-
- var factory:ChartItemRendererFactory = _strand.getBeadByType(IDataProviderItemRendererMapper) as ChartItemRendererFactory;
- var n:int = factory.seriesRenderers.length;
-
- var xAxis:IHorizontalAxisBead;
- if (_strand.getBeadByType(IHorizontalAxisBead)) xAxis = _strand.getBeadByType(IHorizontalAxisBead) as IHorizontalAxisBead;
- var xAxisOffset:Number = xAxis == null ? 0 : xAxis.axisHeight;
- 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 ypos:Number = 0;
- var useWidth:Number = (UIBase(_strand).width / n) - gap - yAxisOffset;
- var useHeight:Number = UIBase(_strand).height - xAxisOffset;
-
- var maxYValue:Number = 0;
- var series:Array = IChart(_strand).series;
- trace("There are "+series.length+" series in this chart");
-
- var barValues:Array = [];
- var maxValue:Number = 0;
- var scaleFactor:Number = 1;
-
- for (var i:int=0; i < n; i++)
- {
- barValues.push({totalValue:0, scaleFactor:0});
-
- for (var s:int = 0; s < series.length; s++)
- {
- var bcs:BarChartSeries = series[s] as BarChartSeries;
- var m:Array = factory.seriesRenderers[i] as Array;
- var item:IChartItemRenderer = m[s] as IChartItemRenderer;
- var data:Object = item.data;
- var field:String = bcs.yField;
-
- var yValue:Number = Number(data[field]);
- barValues[i].totalValue += yValue;
- }
-
- maxValue = Math.max(maxValue, barValues[i].totalValue);
- }
-
- scaleFactor = useHeight/maxValue;
-
- for (i=0; i < n; i++)
- {
- m = factory.seriesRenderers[i] as Array;
- ypos = useHeight;
- for (s=0; s < m.length; s++)
- {
- var child:IChartItemRenderer = m[s] as IChartItemRenderer;
- data = child.data
- yValue = Number(data[child.yField]);
-
- child.x = xpos;
- child.width = useWidth;
- child.y = ypos - yValue*scaleFactor;
- child.height = yValue*scaleFactor;
-
- ypos = child.y;
- }
-
- xpos += gap + useWidth;
- }
-
- IEventDispatcher(_strand).dispatchEvent(new Event("layoutComplete"));
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/86916b5e/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
new file mode 100644
index 0000000..f3b40d6
--- /dev/null
+++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/layouts/StackedColumnChartLayout.as
@@ -0,0 +1,173 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.beads.ChartItemRendererFactory;
+ import org.apache.flex.charts.core.ICartesianChartLayout;
+ import org.apache.flex.charts.core.IChart;
+ import org.apache.flex.charts.core.IChartItemRenderer;
+ import org.apache.flex.charts.core.IHorizontalAxisBead;
+ import org.apache.flex.charts.core.IVerticalAxisBead;
+ import org.apache.flex.charts.supportClasses.BarChartSeries;
+ import org.apache.flex.core.IBeadLayout;
+ import org.apache.flex.core.IDataProviderItemRendererMapper;
+ import org.apache.flex.core.ILayoutParent;
+ import org.apache.flex.core.IStrand;
+ 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 implements IBeadLayout, ICartesianChartLayout
+ {
+ /**
+ * constructor
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function StackedColumnChartLayout()
+ {
+ }
+
+ 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);
+ }
+
+ 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 changeHandler(event:Event):void
+ {
+ var layoutParent:ILayoutParent = _strand.getBeadByType(ILayoutParent) as ILayoutParent;
+
+ var factory:ChartItemRendererFactory = _strand.getBeadByType(IDataProviderItemRendererMapper) as ChartItemRendererFactory;
+ var n:int = factory.seriesRenderers.length;
+
+ var xAxis:IHorizontalAxisBead;
+ if (_strand.getBeadByType(IHorizontalAxisBead)) xAxis = _strand.getBeadByType(IHorizontalAxisBead) as IHorizontalAxisBead;
+ var xAxisOffset:Number = xAxis == null ? 0 : xAxis.axisHeight;
+ 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 ypos:Number = 0;
+ var useWidth:Number = (UIBase(_strand).width / n) - gap - yAxisOffset;
+ var useHeight:Number = UIBase(_strand).height - xAxisOffset;
+
+ var maxYValue:Number = 0;
+ var series:Array = IChart(_strand).series;
+ trace("There are "+series.length+" series in this chart");
+
+ var barValues:Array = [];
+ var maxValue:Number = 0;
+ var scaleFactor:Number = 1;
+
+ for (var i:int=0; i < n; i++)
+ {
+ barValues.push({totalValue:0, scaleFactor:0});
+
+ for (var s:int = 0; s < series.length; s++)
+ {
+ var bcs:BarChartSeries = series[s] as BarChartSeries;
+ var m:Array = factory.seriesRenderers[i] as Array;
+ var item:IChartItemRenderer = m[s] as IChartItemRenderer;
+ var data:Object = item.data;
+ var field:String = bcs.yField;
+
+ var yValue:Number = Number(data[field]);
+ barValues[i].totalValue += yValue;
+ }
+
+ maxValue = Math.max(maxValue, barValues[i].totalValue);
+ }
+
+ scaleFactor = useHeight/maxValue;
+
+ for (i=0; i < n; i++)
+ {
+ m = factory.seriesRenderers[i] as Array;
+ ypos = useHeight;
+ for (s=0; s < m.length; s++)
+ {
+ var child:IChartItemRenderer = m[s] as IChartItemRenderer;
+ data = child.data
+ yValue = Number(data[child.yField]);
+
+ child.x = xpos;
+ child.width = useWidth;
+ child.y = ypos - yValue*scaleFactor;
+ child.height = yValue*scaleFactor;
+
+ ypos = child.y;
+ }
+
+ xpos += gap + useWidth;
+ }
+
+ IEventDispatcher(_strand).dispatchEvent(new Event("layoutComplete"));
+ }
+ }
+}
\ No newline at end of file