问题
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