AxisRenderer's labelRotation property doesn't do anything

拜拜、爱过 提交于 2020-01-25 12:33:39

问题


Despite setting the labelRotation property to 90 in this column chart, the axis labels are horizontal. Is there something additional I need to do?

    <mx:ColumnChart id="myChart" height="100%" width="100%"
                    dataProvider="{myData}"
                    showDataTips="true">
        <mx:horizontalAxis>
            <mx:CategoryAxis id="h1" categoryField="code"/>
        </mx:horizontalAxis>            
        <mx:horizontalAxisRenderers>
            <mx:AxisRenderer axis="{h1}" labelRotation="90" />
        </mx:horizontalAxisRenderers>           
        <mx:series>
            <mx:ColumnSet type="stacked"
                          allowNegativeForStacked="true">
                <mx:series>
                    <mx:ColumnSeries xField="code"
                                     yField="A"
                                     displayName="A"/>
                    <mx:ColumnSeries xField="code"
                                     yField="B"
                                     displayName="B"/>
                    <mx:ColumnSeries xField="code"
                                     yField="C"
                                     displayName="C"/>
                    <mx:ColumnSeries xField="code"
                                     yField="D"
                                     displayName="D"/>
                    <mx:ColumnSeries xField="code"
                                     yField="F"
                                     displayName="F"/>
                </mx:series>
            </mx:ColumnSet>
        </mx:series>
    </mx:ColumnChart>

EDIT: I tried embedding the font, as suggested by Amy and fotomut, but it didn't do anything:

<mx:Style>
 @font-face 
 {
    src:url("../assets/fonts/FRABK.ttf");
fontFamily: myFontFamily; 
embedAsCFF: false; 
 }

ColumnChart 
 { 
        fontFamily: myFontFamily; 
        fontSize: 10; 
     } 

</mx:Style>

回答1:


The key to making the labelRotation work is embedding of fonts. There is a good article on Flex 4.6 here

A simple code example would be to add a style to the mxml file,

<fx:Style>
        @namespace mx "library://ns.adobe.com/flex/mx";

        @font-face{
            src: local("Arial");
            fontFamily: Arial;
            embedAsCFF: false;
        }

        mx|ColumnChart {
            fontFamily: Arial;
            fontSize: 10;
        }
</fx:Style>

EDIT: I confirmed that this works for me using Flex 3.5, by simply changing fx:Style to mx:Style

<mx:Style>
    @namespace mx "library://ns.adobe.com/flex/mx";

    @font-face{
        src: local("Arial");
        fontFamily: Arial;
        embedAsCFF: false;
    }

    mx|ColumnChart {
        fontFamily: Arial;
        fontSize: 10;
    }
</mx:Style>

Perhaps you should try embedding Arial like this first to see if that works?




回答2:


Embed the font used on that label. If for some reason you can't embed the font, sometimes setting the blendMode to "layer" will work.



来源:https://stackoverflow.com/questions/9094921/axisrenderers-labelrotation-property-doesnt-do-anything

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!