public class TMyClass
{
public var value : Number;
public var scale : Number;
public function TMyClass()
{
}
}
[Bindable]
public var myVector : Vector.<TMyClass> = new Vector.<TMyClass>();
yField="value" // the line series property
xFiled="scale"
I am trying to setup a myVector as dataprovider of a LineSeries in a Chart object.
everything going without issue on the build, but when i am executing it – there is an error that the property “value” doesn’t exists.
If I switch the dataprovider to ArrayCollection – everything is going fine.
- Could Vector be used as dataprovider to a Chart series object ?
No, you cannot use the
Vectorclass as the dataProvider. Even thoughdataProviderproperty is typed asObject, it has some expectations of what that object should be.The setter method for the
dataProviderproperty of aLineSeries(and assuming other chart series objects) is defined in the classChartElement. If you look at that setter method, it eventually gets to a series ofifstatements where it checks the type of thedataProvideryou’ve passed in. It checks to see if thedataProvideris one of the following types:ArrayArrayCollectionXMLListXMLListCollectionListCollectionViewIListorICollectionViewinterfacesIf you want to use a
Vector, you can wrap yourVectorin class that implementsIListorICollectionView.People have written classes that wrap a Vector and implement the
IListinterface, myself included. This allows you to useVector‘s with generally any Flex component that has adataProviderproperty.A design goal of my implementation was to avoid all the casting that other people’s implementations were doing (never got around to doing any performance tests though).