1 <?xml version="1.0" encoding="utf-8"?>
2 <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
3 xmlns:amcharts="http://www.amcharts.com/com_internal"
4 xmlns:local="*"
5 layout="absolute"
6 backgroundColor="#FFCC32" creationComplete="init();"
7 width="860"
8 height="400">
9
10 <mx:Script>
11 <![CDATA[
12 import mx.collections.ArrayCollection;
13 import mx.controls.Button;
14 import mx.controls.Text;
15 import mx.core.UIComponent;
16 import mx.core.UITextField;
17
18 import org.osmf.layout.AbsoluteLayoutFacet;
19
20 import spark.components.TextArea;
21
22 [Bindable]
23 private var chartData:ArrayCollection = new ArrayCollection([
24 {year:new Date(2009,10,2), value:-0.307},
25 {year:new Date(1951,0), value:-0.168},
26 {year:new Date(1952,0), value:-0.073},
27 {year:new Date(1953,0), value:-0.027},
28 {year:new Date(1954,0), value:-0.251},
29 {year:new Date(1955,0), value:-0.281},
30 {year:new Date(1956,0), value:-0.348},
31 {year:new Date(1957,0), value:-0.074},
32 {year:new Date(1958,0), value:-0.011},
33 {year:new Date(1959,0), value:-0.074},
34 {year:new Date(1960,0), value:-0.124},
35 {year:new Date(1961,0), value:-0.024},
36 {year:new Date(1962,0), value:-0.022},
37 {year:new Date(1963,0), value:0.000},
38 {year:new Date(1964,0), value:-0.296},
39 {year:new Date(1965,0), value:-0.217},
40 {year:new Date(1966,0), value:-0.147},
41 {year:new Date(1967,0), value:-0.150},
42 {year:new Date(1968,0), value:-0.160},
43 {year:new Date(1969,0), value:-0.011},
44 {year:new Date(1970,0), value:-0.068},
45 {year:new Date(1971,0), value:-0.190},
46 {year:new Date(1972,0), value:-0.056},
47 {year:new Date(1973,0), value:0.077},
48 {year:new Date(1974,0), value:-0.213},
49 {year:new Date(1975,0), value:-0.170},
50 {year:new Date(1976,0), value:-0.254},
51 {year:new Date(1977,0), value:0.019},
52 {year:new Date(1978,0), value:-0.063},
53 {year:new Date(1979,0), value:0.050},
54 {year:new Date(1980,0), value:0.077},
55 {year:new Date(1981,0), value:0.120},
56 {year:new Date(1982,0), value:0.011},
57 {year:new Date(1983,0), value:0.177},
58 {year:new Date(1984,0), value:-0.021},
59 {year:new Date(1985,0), value:-0.037},
60 {year:new Date(1986,0), value:0.030},
61 {year:new Date(1987,0), value:0.179},
62 {year:new Date(1988,0), value:0.180},
63 {year:new Date(1989,0), value:0.104},
64 {year:new Date(1990,0), value:0.255},
65 {year:new Date(1991,0), value:0.210},
66 {year:new Date(1992,0), value:0.065},
67 {year:new Date(1993,0), value:0.110},
68 {year:new Date(1994,0), value:0.172},
69 {year:new Date(1995,0), value:0.269},
70 {year:new Date(1996,0), value:0.141},
71 {year:new Date(1997,0), value:0.353},
72 {year:new Date(1998,0), value:0.548},
73 {year:new Date(1999,0), value:0.298},
74 {year:new Date(2000,0), value:0.267},
75 {year:new Date(2001,0), value:0.411},
76 {year:new Date(2002,0), value:0.462},
77 {year:new Date(2003,0), value:0.470},
78 {year:new Date(2004,0), value:0.445},
79 {year:new Date(2005,0), value:0.470}]);
80
81 private function changeType(event:MouseEvent):void{
82 g0.type = String(event.target.value);
83 }
84
85 private function init():void
86 {
87 var div:Div_xiang = new Div_xiang('B相',0,0,chart);
88 }
89
90 private function init1():void
91 {
92
93 var testrect:Sprite = new Sprite();
94 testrect.buttonMode=true;
95 testrect.doubleClickEnabled=true;
96 testrect.alpha = 0.8;
97 var field:TextField = new TextField();
98 var textformat:TextFormat = new TextFormat();
99 textformat.size = 30;
100 field.text = "A相";
101 field.alpha = 0.8;
102 field.autoSize = TextFieldAutoSize.CENTER;
103 field.background=true;
104 field.backgroundColor=0xFFFFFF;
105 field.setTextFormat(textformat);
106 // field.width =40;
107 // field.height = 40;
108
109 testrect.graphics.beginFill(0xFFFFFF, 0.8);
110 testrect.graphics.drawRect(75,75,60,40);
111 testrect.graphics.endFill();
112
113 // testrect.x = 10;
114 // testrect.y = 10;
115 // testrect.width = 200;
116 // testrect.height = 200;
117 testrect.addChildAt(field,0);
118 chart.addChild(testrect);
119 }
120
121 ]]>
122 </mx:Script>
123
124 <mx:VBox width="100%" height="100%">
125 <local:SuperhanAmSerialChart
126 id="chart"
127 width="100%"
128 height="100%"
129 marginTop="15"
130 marginLeft="60"
131 marginRight="50"
132 dataProvider="{chartData}"
133 categoryField="year"
134 plotAreaFillAlphas="[0]">
135 <!--曲线-->
136 <local:graphs>
137 <amcharts:AmGraph
138 id="g0"
139 lineColor="#CC0000"
140 fillColors="[#CC0000]"
141 negativeLineColor="#009900"
142 negativeFillColors="[#009900]"
143 fillAlphas="[0.3]"
144 valueField="value"
145 type="smoothedLine"/>
146 </local:graphs>
147 <!--X轴属性-->
148 <local:categoryAxis>
149 <amcharts:CategoryAxis
150 parseDates="true"
151 minPeriod="MM"
152 axisColor="#FFFFFF"
153 gridColor="#FFFFFF"
154 gridAlpha="0.5"
155 dashLength="5"
156 gridCount="15" inside="false" color="black" />
157 </local:categoryAxis>
158 <!--Y轴属性-->
159 <local:valueAxes>
160 <amcharts:ValueAxis color="black" axisColor="#FFFFFF" gridColor="#FFFFFF" gridAlpha="1" dashLength="5">
161 <amcharts:guides>
162 <amcharts:Guide value="4.87" lineColor="#FFFFFF" lineAlpha="1" inside="true" dashLength="0" balloonText="Average GDP grow in 2004 was 4.87%"/>
163 </amcharts:guides>
164 </amcharts:ValueAxis>
165 </local:valueAxes>
166 <!--鼠标移动标记-->
167 <local:chartCursor>
168 <amcharts:ChartCursor cursorPosition="mouse" categoryBalloonDateFormat="YYYY"/>
169 </local:chartCursor>
170 <!--最上端拖动条-->
171 <local:chartScrollbar>
172 <amcharts:ChartScrollbar
173 graph="{g0}"
174 backgroundAlpha="0.1"
175 backgroundColor="#000000"
176 selectedBackgroundColor="#FFCC32"/>
177 </local:chartScrollbar>
178 <!--右上角显示全部按钮-->
179 <local:zoomOutButton>
180 <mx:LinkButton rollOverColor="#FFFFFF" label="全部"/>
181 </local:zoomOutButton>
182 </local:SuperhanAmSerialChart>
183
184 <mx:HBox>
185 <mx:Spacer width="50"/>
186 <mx:RadioButton groupName="g1" click="{changeType(event)}" value="line" label="line"/>
187 <mx:RadioButton groupName="g1" click="{changeType(event)}" value="smoothedLine" label="smoothed line" selected="true"/>
188 <mx:RadioButton groupName="g1" click="{changeType(event)}" value="column" label="columns"/>
189 <mx:RadioButton groupName="g1" click="{changeType(event)}" value="step" label="step"/>
190 </mx:HBox>
191
192 <mx:Spacer height="10"/>
193 </mx:VBox>
194 </mx:Application>