修改flex chart中Legend的字体样式

最近在弄FLEX的图表, 发现CHART 中的Legend 的字体通过直接设置Style 并没有办法改变字体大小.

google 了下, 发现了这个方法: 通过派生LegendItem类,并设置Legend的ItemClass属性来实现。

 

LegendItem 是Lengend 的元素, 就是里面一个一个的图示. 通过派生这个类, 就可以修改其相应的样式.

1. 派生LegendItem 类, 并设置样式.

  BigFontLegendItem.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:LegendItem xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx"
               styleName="ChineseFont">
    <fx:Style>  
        .ChineseFont  
        {  
            fontSize:12;  
        }  
    </fx:Style> 
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
</mx:LegendItem>

2. 然后定义样式, 在 Legend 中直接指定legendItemClass 为  BigFontLegendItem

<mx:Legend legendItemClass="com.BigFontLegendItem" /> 

这样就可以设置Legend 中的字体大小或者样式了.

原文:http://enboga.iteye.com/blog/317341

posted @ 2013-09-10 16:28  小小有  阅读(572)  评论(0编辑  收藏  举报