绘制LineChart线形图

<fx:Declarations>
		<!-- 将非可视元素(例如服务、值对象)放在此处 -->
		
		<s:SolidColorStroke id="s1" color="red" weight="2"/>
		
	</fx:Declarations>
	
	<fx:Script>
		<![CDATA[
			import model.Person;
			
			import mx.collections.ArrayCollection;
			
			[Bindable]
			public var personHeightColl:ArrayCollection = new ArrayCollection();
			
			public function initApp():void
			{
				var height:int = 50;
				for(var i:int = 1; i <= 6; i++)
				{
					countPersonHeight(i,height);
					height = height + 10;
				}
			}
			
			public function countPersonHeight(age:int , height:int):ArrayCollection
			{
				var person:Person = new Person();
				
				person.age = age;
				person.height = height;
				
				personHeightColl.addItem(person);
				
				return personHeightColl;
			}
			
			
		]]>
	</fx:Script>
	
	<mx:LineChart id="personLineChart" x="10" y="160" width="50%" height="50%" dataProvider="{personHeightColl}" showDataTips="true">
		
		<!--定义X轴所显示的项-->
		<mx:horizontalAxis>
			<mx:CategoryAxis  categoryField="age"/>
		</mx:horizontalAxis>
		
		<!--定义Y轴显示的项及使用的曲线-->
		<mx:series>
			<mx:LineSeries yField="height" form="curve" displayName="Height" lineStroke="{s1}"/>
		</mx:series>
		
	</mx:LineChart>
	
	<!--添加图例-->
	<mx:Legend y="80"  dataProvider="{personLineChart}"/>
	



绘制LineChart线形图_第1张图片

你可能感兴趣的:(绘制LineChart线形图)