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], [0 xffaaaaaa, 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 ")
}
}
}