Flex:动态创建的系列未显示在图表上?
我有以下课程:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否影响了新创建的系列的垂直轴?
Did you affect a vertical axis to your newly created series ?
您需要将 public var rawData 设为 getter/setter 对,以便可以用它填充 ArrayCollection。所以:
You need to make public var rawData into a getter/setter pair, so you can populate the ArrayCollection with it. So: