就个人而言,我会创建一个接口,这两个模型都会实现。例如,
public interface IFooBar {
function get myLabel():String;
function get myAmount():Number;
}
public class CostsByNature implements IFooBar {
//your code here
public var natureLabel:String;
public var amount:String;
public function get myLabel():String {
return this.natureLabel;
}
public function get myAmount():Number {
return this.amount;
}
}
public class ProjectDTO implements IFooBar {
//your code here
public var projectLabel:String;
public var projectAmount:String;
public function get myLabel():String {
return this.projectLabel;
}
public function get myAmount():Number {
return this.projectAmount;
}
}
在您的饼图中,始终绑定到“myLabel”和“myAmount”。在您的饼图监听器中,在 dataProviders 之间切换。
public function myListener(e:ChartItemEvent):void {
mainDataProvider = e.hitData.item.costsByNature;
}
祝你好运!