CSDN博客

img milefo95

FLEX 3.0 DataGrid & PieChart with XML

发表于2008/10/1 22:51:00  537人阅读

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

 <mx:Script>
  <![CDATA[
     [Bindable]
     public var xmlTest:XML=<BOOKCollection>
            <BookItem>
                <Name>Thinking In Java</Name>
                <Type>JAVA</Type>
                <Count>100</Count>
            </BookItem>  
        
            <BookItem>
                <Name>Thinking In C++</Name>
                <Type>C++</Type>
                <Count>200</Count>
            </BookItem>  
       
            <BookItem>
                <Name>Flex First Step</Name>
                <Type>Flex</Type>
                <Count>200</Count>
            </BookItem>  
        </BOOKCollection>;
                               
  ]]>
 </mx:Script>
 
 <!-- 图表 从XML中获取填充数据 注意:XML节点名区分大小写 -->
 <mx:HBox x="22.25" y="177" width="589.5" height="284">
  <mx:DataGrid height="270" dataProvider="{xmlTest.BookItem}" width="257">
   <mx:columns>
    <mx:DataGridColumn headerText="NAME" dataField="Name"/>
    <mx:DataGridColumn headerText="COUNT" dataField="Count"/>
   </mx:columns>
  </mx:DataGrid>
  
  <!-- 饼图 从XML中获取填充数据 -->
  <mx:Panel width="320" height="276" layout="absolute" title="CUEPOINT PIE CHART">
   <mx:PieChart x="10" y="0" id="piechart1" dataProvider="{xmlTest.BookItem}" width="100%" height="100%" showDataTips="true">
    <mx:series>
     <mx:PieSeries field="Count" nameField="Name" labelPosition="callout"/>
    </mx:series>
   </mx:PieChart>
   <mx:Legend dataProvider="{piechart1}"/>
  </mx:Panel>
 </mx:HBox>
</mx:Application>

0 0

相关博文

我的热门文章

img
取 消
img