Flex中如何通过markerWidth和markerHeight样式设置Legend的marker的宽度和高度的例子

By Minidxer | September 29, 2008

接下来的例子演示了Flex中如何通过markerWidth和markerHeight样式,设置Legend的marker的宽度和高度。

让我们先来看一下Demo可以右键View Source或点击这里察看源代码):


下面是完整代码(或点击这里察看):

Download: main.mxml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application name="Legend_markerHeight_test"
  3.         xmlns:mx="http://www.adobe.com/2006/mxml"
  4.         layout="vertical"
  5.         verticalAlign="middle"
  6.         backgroundColor="white">
  7.  
  8.     <mx:XMLListCollection id="dp">
  9.         <mx:source>
  10.             <mx:XMLList>
  11.                 <product label="Product 1" data="3" />
  12.                 <product label="Product 2" data="1" />
  13.                 <product label="Product 3" data="4" />
  14.                 <product label="Product 4" data="1" />
  15.                 <product label="Product 5" data="5" />
  16.                 <product label="Product 6" data="9" />
  17.             </mx:XMLList>
  18.         </mx:source>
  19.     </mx:XMLListCollection>
  20.  
  21.     <mx:ApplicationControlBar dock="true">
  22.         <mx:Form styleName="plain">
  23.             <mx:FormItem label="markerWidth:">
  24.                 <mx:HSlider id="markerWSlider"
  25.                         minimum="5"
  26.                         maximum="15"
  27.                         value="10"
  28.                         snapInterval="1"
  29.                         tickInterval="1"
  30.                         liveDragging="true" />
  31.             </mx:FormItem>
  32.             <mx:FormItem label="markerHeight:">
  33.                 <mx:HSlider id="markerHSlider"
  34.                         minimum="5"
  35.                         maximum="15"
  36.                         value="10"
  37.                         snapInterval="1"
  38.                         tickInterval="1"
  39.                         liveDragging="true" />
  40.             </mx:FormItem>
  41.         </mx:Form>
  42.     </mx:ApplicationControlBar>
  43.  
  44.     <mx:Panel id="panel"
  45.             styleName="opaquePanel"
  46.             width="100%"
  47.             height="100%">
  48.         <mx:PieChart id="pieChart"
  49.                 dataProvider="{dp}"
  50.                 showDataTips="true"
  51.                 height="100%"
  52.                 width="100%">
  53.             <mx:series>
  54.                 <mx:PieSeries id="pieSeries"
  55.                         field="@data"
  56.                         nameField="@label"
  57.                         filters="[]" />
  58.             </mx:series>
  59.         </mx:PieChart>
  60.         <mx:ControlBar>
  61.             <mx:Legend id="legend"
  62.                     dataProvider="{pieChart}"
  63.                     direction="horizontal"
  64.                     horizontalGap="100"
  65.                     markerWidth="{markerWSlider.value}"
  66.                     markerHeight="{markerHSlider.value}" />
  67.         </mx:ControlBar>
  68.     </mx:Panel>
  69.  
  70. </mx:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子

Topics: Legend | No Comments » | 335 views Tags: , ,

Search Posts