首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >基于Java的弹性图的ArrayCollections

基于Java的弹性图的ArrayCollections
EN

Stack Overflow用户
提问于 2012-04-30 17:30:45
回答 1查看 341关注 0票数 1

当我们创建弹性图表时,例如柱状图,我们必须绑定一个类似如下的ArrayCollection:

代码语言:javascript
复制
[Bindable]
private var chartData:ArrayCollection = new ArrayCollection([
    {X: "Jan", Y: 10},
    {X: "Feb", Y: 20},
    {X: "Mar", Y: 30}
]);

如果我需要从Java后端获取这些数据,那么在java中可以使用哪种数据结构?

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-04-30 20:37:26

尝尝这个

代码语言:javascript
复制
// this class is used for the arraylist/collection of point X and Y
// on actionscript side you will see the property you declare as public 
public class ChartPoint {
    public String X;
    public String Y;      
}



public class ChartData{          
 // method called from remoteobject from actionscript
 // it will return a java arraylist of type chartpoint
 // actionscript will receive an arraycollection with the property of 
 // ChartPoint you declared public
  public ArrayList<ChartPoint> getValuesFromChart()
  { 
   ArrayList<ChartPoint> chartData = new ArrayList<ChartPoint>();
   ....
   // initialization and fill the chartData list...
   return chartData;
  }
}

在actionscript中,您将使用AMF协议...

代码语言:javascript
复制
ro = new RemoteObject();
ro.destination = "destination"; // configured in blazeds/tomcat server
var cs:ChannelSet = new ChannelSet();
var customChannel:Channel = new AMFChannel("my-amf", "http://your-amf-channel");
cs.addChannel(customChannel);
ro.channelSet = cs;             
ro.addEventListener(ResultEvent.RESULT,
    function(e:ResultEvent):void{       
        if (e.result != null)
        {                       
            // you have a result...
                   this.chartData = e.result;
        }               
    });         
ro.addEventListener(FaultEvent.FAULT,function(e:FaultEvent):void{ 
 // manage the error
});         

ro.getValuesFromChart();
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10381351

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档