Flex中如何通过markerWidth和markerHeight样式设置Legend的marker的宽度和高度的例子
By Minidxer | September 29, 2008
接下来的例子演示了Flex中如何通过markerWidth和markerHeight样式,设置Legend的marker的宽度和高度。
让我们先来看一下Demo(可以右键View Source或点击这里察看源代码):
下面是完整代码(或点击这里察看):
Download: main.mxml
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application name="Legend_markerHeight_test"
- xmlns:mx="http://www.adobe.com/2006/mxml"
- layout="vertical"
- verticalAlign="middle"
- backgroundColor="white">
- <mx:XMLListCollection id="dp">
- <mx:source>
- <mx:XMLList>
- <product label="Product 1" data="3" />
- <product label="Product 2" data="1" />
- <product label="Product 3" data="4" />
- <product label="Product 4" data="1" />
- <product label="Product 5" data="5" />
- <product label="Product 6" data="9" />
- </mx:XMLList>
- </mx:source>
- </mx:XMLListCollection>
- <mx:ApplicationControlBar dock="true">
- <mx:Form styleName="plain">
- <mx:FormItem label="markerWidth:">
- <mx:HSlider id="markerWSlider"
- minimum="5"
- maximum="15"
- value="10"
- snapInterval="1"
- tickInterval="1"
- liveDragging="true" />
- </mx:FormItem>
- <mx:FormItem label="markerHeight:">
- <mx:HSlider id="markerHSlider"
- minimum="5"
- maximum="15"
- value="10"
- snapInterval="1"
- tickInterval="1"
- liveDragging="true" />
- </mx:FormItem>
- </mx:Form>
- </mx:ApplicationControlBar>
- <mx:Panel id="panel"
- styleName="opaquePanel"
- width="100%"
- height="100%">
- <mx:PieChart id="pieChart"
- dataProvider="{dp}"
- showDataTips="true"
- height="100%"
- width="100%">
- <mx:series>
- <mx:PieSeries id="pieSeries"
- field="@data"
- nameField="@label"
- filters="[]" />
- </mx:series>
- </mx:PieChart>
- <mx:ControlBar>
- <mx:Legend id="legend"
- dataProvider="{pieChart}"
- direction="horizontal"
- horizontalGap="100"
- markerWidth="{markerWSlider.value}"
- markerHeight="{markerHSlider.value}" />
- </mx:ControlBar>
- </mx:Panel>
- </mx:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子
Topics:
Legend |
No Comments » |
335 views
Tags: Legend, markerHeight, markerWidth