This is an automated email from the ASF dual-hosted git repository. aharui pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
commit b3dc0b32301a5b778182f7f95908ec61b57236f6 Author: Alex Harui <aha...@apache.org> AuthorDate: Thu Nov 1 14:49:47 2018 -0700 line and area chart rendering. May need to move top/left code to UIComponent so that all UIComponents default to positioning at 0,0 like they do in Flash --- .../royale/mx/charts/chartClasses/ChartElement.as | 4 + .../royale/mx/charts/renderers/AreaRenderer.as | 22 ++++++ .../royale/mx/charts/renderers/LineRenderer.as | 22 ++++++ .../src/main/royale/mx/charts/series/AreaSeries.as | 85 +++++++++++++++------- .../src/main/royale/mx/charts/series/LineSeries.as | 42 +++++++---- 5 files changed, 135 insertions(+), 40 deletions(-) diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/charts/chartClasses/ChartElement.as b/frameworks/projects/MXRoyale/src/main/royale/mx/charts/chartClasses/ChartElement.as index 424e6e7..910d33b 100644 --- a/frameworks/projects/MXRoyale/src/main/royale/mx/charts/chartClasses/ChartElement.as +++ b/frameworks/projects/MXRoyale/src/main/royale/mx/charts/chartClasses/ChartElement.as @@ -668,6 +668,10 @@ public class ChartElement extends DualStyleObject implements IChartElement2 override public function addedToParent():void { super.addedToParent(); + COMPILE::JS + { + element.style.position = "absolute"; + } commitProperties(); measure(); updateDisplayList(getExplicitOrMeasuredWidth(), getExplicitOrMeasuredHeight()); diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/charts/renderers/AreaRenderer.as b/frameworks/projects/MXRoyale/src/main/royale/mx/charts/renderers/AreaRenderer.as index ce61324..19960bf 100644 --- a/frameworks/projects/MXRoyale/src/main/royale/mx/charts/renderers/AreaRenderer.as +++ b/frameworks/projects/MXRoyale/src/main/royale/mx/charts/renderers/AreaRenderer.as @@ -29,6 +29,10 @@ import mx.graphics.IFill; import mx.graphics.IStroke; import mx.graphics.SolidColorStroke; import mx.skins.ProgrammaticSkin; +COMPILE::JS +{ + import org.apache.royale.core.WrappedHTMLElement; +} /** * The default class used to render the area @@ -76,6 +80,15 @@ public class AreaRenderer extends ProgrammaticSkin implements IDataRenderer super(); } + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + var element:WrappedHTMLElement = super.createElement(); + positioner.style.left = "0px"; + positioner.style.top = "0px"; + return element; + } + //-------------------------------------------------------------------------- // // Properties @@ -197,6 +210,15 @@ public class AreaRenderer extends ProgrammaticSkin implements IDataRenderer g.endFill(); } + + override public function addedToParent():void + { + super.addedToParent(); + COMPILE::JS + { + element.style.position = "absolute"; + } + } } } diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/charts/renderers/LineRenderer.as b/frameworks/projects/MXRoyale/src/main/royale/mx/charts/renderers/LineRenderer.as index 39b44ba..8852bd9 100644 --- a/frameworks/projects/MXRoyale/src/main/royale/mx/charts/renderers/LineRenderer.as +++ b/frameworks/projects/MXRoyale/src/main/royale/mx/charts/renderers/LineRenderer.as @@ -24,6 +24,10 @@ import mx.charts.chartClasses.GraphicsUtilities; import mx.core.IDataRenderer; import mx.graphics.IStroke; import mx.skins.ProgrammaticSkin; +COMPILE::JS +{ + import org.apache.royale.core.WrappedHTMLElement; +} /** * A simple implementation of a line segment renderer @@ -59,6 +63,15 @@ public class LineRenderer extends ProgrammaticSkin implements IDataRenderer { super(); } + + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + var element:WrappedHTMLElement = super.createElement(); + positioner.style.left = "0px"; + positioner.style.top = "0px"; + return element; + } //-------------------------------------------------------------------------- // @@ -127,6 +140,15 @@ public class LineRenderer extends ProgrammaticSkin implements IDataRenderer stroke,form); } + + override public function addedToParent():void + { + super.addedToParent(); + COMPILE::JS + { + element.style.position = "absolute"; + } + } } } diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/charts/series/AreaSeries.as b/frameworks/projects/MXRoyale/src/main/royale/mx/charts/series/AreaSeries.as index f37c55c..f2cfa26 100644 --- a/frameworks/projects/MXRoyale/src/main/royale/mx/charts/series/AreaSeries.as +++ b/frameworks/projects/MXRoyale/src/main/royale/mx/charts/series/AreaSeries.as @@ -20,10 +20,6 @@ package mx.charts.series { -import mx.core.UIComponent; -import org.apache.royale.geom.Point; -import org.apache.royale.geom.Rectangle; - import mx.charts.DateTimeAxis; import mx.charts.HitData; import mx.charts.chartClasses.BoundedValue; @@ -49,11 +45,18 @@ import mx.core.IDataRenderer; import mx.core.IFactory; import mx.core.IFlexDisplayObject; import mx.core.IFlexModuleFactory; +import mx.core.UIComponent; import mx.core.mx_internal; import mx.graphics.IFill; import mx.graphics.IStroke; import mx.graphics.SolidColor; import mx.graphics.SolidColorStroke; +import mx.skins.ProgrammaticSkin; + +import org.apache.royale.geom.Point; +import org.apache.royale.geom.Rectangle; + +import mx.skins.ProgrammaticSkin; import mx.styles.CSSStyleDeclaration; import mx.styles.ISimpleStyleClient; @@ -76,17 +79,6 @@ include "../styles/metadata/ItemRendererStyles.as" [Style(name="adjustedRadius", type="Number", format="Length", inherit="yes")] -/** - * Sets the fill for the area. You can specify either an object implementing the - * IFill interface, or a number representing a solid color value. You can also specify a solid fill using CSS. - * - * @langversion 3.0 - * @playerversion Flash 9 - * @playerversion AIR 1.1 - * @productversion Flex 3 - */ -[Style(name="areaFill", type="mx.graphics.IFill", inherit="no")] - /** * The class that the series uses to represent the filled area on the chart. This class is instantiated once per series. * Classes used as areaRenderers should implement the IFlexDisplayObject, ISimpleStyleClient, and IDataRenderer @@ -100,17 +92,6 @@ include "../styles/metadata/ItemRendererStyles.as" */ [Style(name="areaRenderer", type="mx.core.IFactory", inherit="no")] -/** - * Sets the line style for the area. - * You use a Stroke object to define the stroke. - * You can specify the itemRenderer in MXML or using styles. - * - * @langversion 3.0 - * @playerversion Flash 9 - * @playerversion AIR 1.1 - * @productversion Flex 3 - */ -[Style(name="areaStroke", type="mx.graphics.IStroke", inherit="no")] /** * Specifies an Array of fill objects that define the fill for @@ -424,6 +405,56 @@ public class AreaSeries extends Series implements IStackable2 //-------------------------------------------------------------------------- //----------------------------------- + // areaFill + //----------------------------------- + + /** + * Sets the fill for the area. You can specify either an object implementing the + * IFill interface, or a number representing a solid color value. You can also specify a solid fill using CSS. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function get areaFill():mx.graphics.IFill + { + return getStyle("areaFill"); + } + public function set areaFill(value:mx.graphics.IFill):void + { + setStyle("areaFill", value); + if (parent && areaStroke) + updateDisplayList(width, height); + } + + //----------------------------------- + // areaStroke + //----------------------------------- + + /** + * Sets the line style for the area. + * You use a Stroke object to define the stroke. + * You can specify the itemRenderer in MXML or using styles. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + [Style(name="areaStroke", type="mx.graphics.IStroke", inherit="no")] + public function get areaStroke():mx.graphics.IStroke + { + return getStyle("areaStroke"); + } + public function set areaStroke(value:mx.graphics.IStroke):void + { + setStyle("areaStroke", value); + if (parent && areaFill) + updateDisplayList(width, height); + } + + //----------------------------------- // fillFunction //----------------------------------- [Bindable] @@ -1026,6 +1057,8 @@ public class AreaSeries extends Series implements IStackable2 _transition = false; } + if (_areaRenderer is ProgrammaticSkin) + (_areaRenderer as ProgrammaticSkin).invalidateDisplayList(); // some visual changes don't change the size _areaRenderer.setActualSize(unscaledWidth, unscaledHeight); (_areaRenderer as IDataRenderer).data = renderData; diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/charts/series/LineSeries.as b/frameworks/projects/MXRoyale/src/main/royale/mx/charts/series/LineSeries.as index 387ace1..32c1918 100644 --- a/frameworks/projects/MXRoyale/src/main/royale/mx/charts/series/LineSeries.as +++ b/frameworks/projects/MXRoyale/src/main/royale/mx/charts/series/LineSeries.as @@ -179,19 +179,6 @@ include "../styles/metadata/ItemRendererStyles.as" [Style(name="lineSegmentRenderer", type="mx.core.IFactory", inherit="no")] /** - * Sets the stroke for the actual line segments. - * The default value for a LineChart control is orange (<code>0xE48701</code>). - * The default color for a LineSeries used in a CartesianChart control is black (<code>0x000000</code>). - * The default value for the width is 3. - * - * @langversion 3.0 - * @playerversion Flash 9 - * @playerversion AIR 1.1 - * @productversion Flex 3 - */ -[Style(name="lineStroke", type="mx.graphics.IStroke", inherit="no")] - -/** * Specifies the radius, in pixels, of the chart elements for the data points. * This property applies only if you specify an item renderer * using the <code>itemRenderer</code> property. @@ -654,10 +641,37 @@ public class LineSeries extends Series return LineSeriesSegment; } + + //---------------------------------- + // lineStroke + //---------------------------------- + + /** + * Sets the stroke for the actual line segments. + * The default value for a LineChart control is orange (<code>0xE48701</code>). + * The default color for a LineSeries used in a CartesianChart control is black (<code>0x000000</code>). + * The default value for the width is 3. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function get lineStroke():IStroke + { + return getStyle("lineStroke"); + } + public function set lineStroke(value:IStroke):void + { + setStyle("lineStroke", value); + if (parent) + updateDisplayList(width, height); + } + //---------------------------------- // radius //---------------------------------- - + [Inspectable(category="Styles")] /**