flare 之無需在jsp檔案中寫graphml 檔案再在As檔案中讀取這個檔案

來源:互聯網
上載者:User

package {
  import flare.animate.Transitioner;
  import flare.scale.ScaleType;
  import flare.util.palette.ColorPalette;
  import flare.util.palette.ShapePalette;
  import flare.vis.Visualization;
  import flare.vis.controls.ClickControl;
  import flare.vis.data.Data;
  import flare.vis.data.EdgeSprite;
  import flare.vis.data.NodeSprite;
  import flare.vis.operator.encoder.ColorEncoder;
  import flare.vis.operator.encoder.ShapeEncoder;
  import flare.vis.operator.encoder.SizeEncoder;
  import flare.vis.operator.layout.AxisLayout;
  
  import flash.display.Sprite;
  import flash.events.Event;
  import flash.geom.Rectangle;
[SWF(width="500",height="400",backgroundColor="#ffffff",frameRade="30")]
  public class Flare_axisLayout extends Sprite
  {
    public function Flare_axisLayout()
    {
      var data:Array=[{x:25,y:23,sex:"male",age:29},{x:32,y:58,sex:"female",age:29}];
      var visual:Visualization=new Visualization(Data.fromArray(data));
      var axis:AxisLayout=new AxisLayout("data.x","data.y");
      visual.bounds=new Rectangle(50,50,400,300);
      visual.operators.add(axis);
      //set the axis style;
      visual.xyAxes.xAxis.lineColor=0xff0000;
      //add nodes to axis;
      var node1:NodeSprite=visual.data.addNode({x:35,y:43,sex:"female",age:10});
      var node2:NodeSprite=visual.data.addNode({x:12,y:27,sex:"unknow",age:2});
      var edge:EdgeSprite=new EdgeSprite(node1,node2,false);
      visual.data.addEdge(edge);
      
      
      //add event listener to visual;note:no nodes;
      var click:ClickControl=new ClickControl(null,1,clickHandler);
      visual.controls.add(click);
      
      var colorpalette:ColorPalette=new ColorPalette([0xffff0000,0xff00ff00,0xff0000ff],[0xffAAAAAA,0xff000000]);
      var shapepalette:ShapePalette=new ShapePalette();
      //add color style to nodes;
      //palette:you just selected color from palette;
      
      var color:ColorEncoder=new ColorEncoder("data.sex",Data.NODES,"fillColor",ScaleType.CATEGORIES,colorpalette);
      visual.operators.add(color);
      //add shape style to nodes;
      var shape:ShapeEncoder=new ShapeEncoder("data.sex");
      visual.operators.add(shape);
      //add properties to nodes and edges;
      var t:Transitioner=new Transitioner(3);
      
      
      visual.data.nodes.setProperty("lineColor",0xffff0000,t);
      visual.data.nodes.setProperty("lineWidth",2,t);
      visual.data.edges.setProperty("lineWidth",2,t);
      visual.data.edges.setProperty("lineColor",0xffff0000,t);
      t.play();
      //according to age property set the size style;
      var size:SizeEncoder=new SizeEncoder("data.age");
      visual.operators.add(size);
      //
      
      this.addChild(visual);
      visual.update();
    }
    private function clickHandler(evt:Event):void{
      trace("click")
    }
  }
}

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.