Flex:动态创建的系列未显示在图表上?

发布于 2024-12-10 07:31:41 字数 1910 浏览 0 评论 0原文

我有以下课程:

package my.controls.charts.series
{
    import mx.charts.series.LineSeries;
    import mx.collections.ArrayCollection;
    import mx.graphics.SolidColorStroke;

    import my.controls.charts.ICommonCharts;

    public class TimeLineSeries extends LineSeries implements ICommonCharts
    {
        [Bindable]
        protected  var dataProviderLineSeries : ArrayCollection;
        public     var rawData                : Array; 

        public function TimeLineSeries( seriesName : String )
        {
            super();
            this.displayName  = seriesName;
            this.yField       = "value";
            this.xField       = "dateBegin";

            this.sortOnXField = true;
            this.filterData   = true;           

            this.setStyle( "form", "segment" ); 

            var stroke : SolidColorStroke = new SolidColorStroke();
                stroke.color    = 0xFF0000;
                stroke.weight   = 1;
            this.setStyle( "lineStroke", stroke );

            rawData                = new Array();
            dataProviderLineSeries = new ArrayCollection();
            this.dataProvider      = dataProviderLineSeries;
        }

        public function Clear() : void
        {
            rawData = [];
            dataProviderLineSeries.removeAll();
        }

        public function ApplyData() : void
        {
            dataProviderLineSeries.removeAll();
            dataProviderLineSeries = new ArrayCollection( rawData );
            dataProviderLineSeries.refresh();

        }
    }
}

在应用程序上我正在尝试以下操作:

dinamicSeries : Array = new Array(); mySeries : TimeLineSeries = new TimeLineSeries( 'chronos' ); mySeries.rawData = randomData(); // 这是一个获取一些随机数据的函数 mySeries.ApplyData(); dinamicSeries.push( mySeries );
mainChart.series = dinamicSeries;

新系列名称出现在图表上,但数据没有出现,并且图表始终保持空白。 - 我做错了什么?

I have the follow class :

package my.controls.charts.series
{
    import mx.charts.series.LineSeries;
    import mx.collections.ArrayCollection;
    import mx.graphics.SolidColorStroke;

    import my.controls.charts.ICommonCharts;

    public class TimeLineSeries extends LineSeries implements ICommonCharts
    {
        [Bindable]
        protected  var dataProviderLineSeries : ArrayCollection;
        public     var rawData                : Array; 

        public function TimeLineSeries( seriesName : String )
        {
            super();
            this.displayName  = seriesName;
            this.yField       = "value";
            this.xField       = "dateBegin";

            this.sortOnXField = true;
            this.filterData   = true;           

            this.setStyle( "form", "segment" ); 

            var stroke : SolidColorStroke = new SolidColorStroke();
                stroke.color    = 0xFF0000;
                stroke.weight   = 1;
            this.setStyle( "lineStroke", stroke );

            rawData                = new Array();
            dataProviderLineSeries = new ArrayCollection();
            this.dataProvider      = dataProviderLineSeries;
        }

        public function Clear() : void
        {
            rawData = [];
            dataProviderLineSeries.removeAll();
        }

        public function ApplyData() : void
        {
            dataProviderLineSeries.removeAll();
            dataProviderLineSeries = new ArrayCollection( rawData );
            dataProviderLineSeries.refresh();

        }
    }
}

on the application i am trying the follow :

dinamicSeries : Array = new Array();
mySeries : TimeLineSeries = new TimeLineSeries( 'chronos' );
mySeries.rawData = randomData(); // it is a function which gain some random data
mySeries.ApplyData();
dinamicSeries.push( mySeries );
mainChart.series = dinamicSeries;

The new series name appear on the chart, but the data doest, and the chart always remains blank.
- What wrong I am doing ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦断已成空 2024-12-17 07:31:41

您是否影响了新创建的系列的垂直轴?

Did you affect a vertical axis to your newly created series ?

请恋爱 2024-12-17 07:31:41

您需要将 public var rawData 设为 getter/setter 对,以便可以用它填充 ArrayCollection。所以:

protected var _rawData:Array;

public function get rawData():Array {
    return _rawData;
}
public function set rawData(value:Array):void {
    if (value != _rawData) {
       _rawData = value;
       dataProviderLineSeries.source = value;
    }
}

You need to make public var rawData into a getter/setter pair, so you can populate the ArrayCollection with it. So:

protected var _rawData:Array;

public function get rawData():Array {
    return _rawData;
}
public function set rawData(value:Array):void {
    if (value != _rawData) {
       _rawData = value;
       dataProviderLineSeries.source = value;
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文