返回 导航

Flex

hangge.com

Flex - 修改图例(Legend )的字体样式和大小

作者:hangge | 2015-09-14 12:34
默认图例文字太小,如果想要修改Legend的字体大小,直接设置Legend的fontSize是没有用的。 

可以通过扩展LegendItem类,并设置Legend的ItemClass属性来实现。 

--- MyLegendItem.as  ---
package com.frontier.qjbdz.views.comp
{
	import mx.charts.LegendItem;
	public class MyLegendItem extends LegendItem{
		public function MyLegendItem(){
			super();
			this.styleName="LegendItemFont";
		}
	}
}

--- Main.mxml ---
<?xml version="1.0"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
			   xmlns:s="library://ns.adobe.com/flex/spark"
			   xmlns:mx="library://ns.adobe.com/flex/mx">
	<fx:Style>
		@namespace s "library://ns.adobe.com/flex/spark";
		@namespace mx "library://ns.adobe.com/flex/mx";
		@namespace comp "com.frontier.qjbdz.views.comp.*";
		
		.LegendItemFont{
			fontSize:12;
		}
	</fx:Style>	
	
	<mx:Legend dataProvider="{linechart}" width="100%" direction="horizontal" 
		paddingLeft="30" color="0x707070"  legendItemClass="{MyLegendItem}"/>	
</s:Application>
评论

全部评论(0)

回到顶部