<mx:Panel title="Line Chart">
<mx:LineChart dataProvider="{myAC}" showDataTips="true">
<mx:horizontalAxis>
<mx:CategoryAxis dataProvider="{myAC}" categoryField="month"/>
</mx:horizontalAxis>
<mx:series>
<mx:LineSeries yField="apple" displayName="Apple"/>
<mx:LineSeries yField="orange" displayName="Orange"/>
<mx:LineSeries yField="banana" displayName="Banana"/>
</mx:series>
</mx:LineChart>
Pie chart
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" backgroundGradientColors="[#f7f794, #adb2ce]">
<mx:Script><![CDATA[
import mx.collections.ArrayCollection;
import mx.utils.ArrayUtil;
]]></mx:Script>
<!-- xml데이터 모델 소스 지정 -->
<mx:Model id="myXML" source="data/data.xml"/>
<!-- XML을 ArrayCollection 데이터로 변환 -->
<mx:ArrayCollection id="myAC" source="{ArrayUtil.toArray(myXML.result)}" />
<mx:Panel title="Pie Chart - apple">
<mx:PieChart dataProvider="{myAC}" showDataTips="true">
<mx:series>
<mx:Array>
<mx:PieSeries field="apple" labelPosition="inside"/>
</mx:Array>
</mx:series>
</mx:PieChart>
</mx:Panel>
<mx:Panel title="Pie Chart - orange">
<mx:PieChart dataProvider="{myAC}" showDataTips="true">
<mx:series>
<mx:Array>
<mx:PieSeries field="orange" labelPosition="inside"/>
</mx:Array>
</mx:series>
</mx:PieChart>
</mx:Panel>
<mx:Panel title="Pie Chart - banana">
<mx:PieChart dataProvider="{myAC}" showDataTips="true">
<mx:series>
<mx:Array>
<mx:PieSeries field="banana" labelPosition="inside"/>
</mx:Array>
</mx:series>
</mx:PieChart>
</mx:Panel>
</mx:Application>
[data.xml]
<data>
<result month="1">
<apple>20</apple>
<orange>15</orange>
<banana>11</banana>
</result>
<result month="2">
<apple>18</apple>
<orange>17</orange>
<banana>23</banana>
</result>
<result month="3">
<apple>18</apple>
<orange>17</orange>
<banana>23</banana>
</result>
<result month="4">
<apple>11</apple>
<orange>13</orange>
<banana>9</banana>
</result>
<result month="5">
<apple>8</apple>
<orange>7</orange>
<banana>3</banana>
</result>
<result month="6">
<apple>11</apple>
<orange>12</orange>
<banana>21</banana>
</result>
<result month="7">
<apple>20</apple>
<orange>10</orange>
<banana>13</banana>
</result>
<result month="8">
<apple>18</apple>
<orange>16</orange>
<banana>29</banana>
</result>
<result month="9">
<apple>28</apple>
<orange>17</orange>
<banana>22</banana>
</result>
<result month="10">
<apple>18</apple>
<orange>17</orange>
<banana>3</banana>
</result>
<result month="11">
<apple>3</apple>
<orange>4</orange>
<banana>9</banana>
</result>
<result month="12">
<apple>1</apple>
<orange>10</orange>
<banana>13</banana>
</result>
</data>
댓글 달기