show data label when the values are negative
I have a bar chart where I'm trying to get the data labels to show. When the values are all positive the data labels appear fine. When I mix in some negative values, the datalabels don't show:
<?xml version="1.0" encoding="utf-8"?>
<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" width="100%" height="100%"
creationComplete="fillArray();"
>
<fx:Script>
<![CDATA[
import flash.events.Event;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
public var array:Object=new Object();
[Bindable]
public var ac:ArrayCollection=new ArrayCollection([]);
private function fillArray():void{
array=new Object();
ac=new ArrayCollection([]);
for(var k:in开发者_如何学JAVAt=-12; k<10; k++){ //datalabels are visible if I start k at 0
array=new Object();
array['val']=k;
array['label']=k;
ac.addItem(array);
}
}
]]>
</fx:Script>
<mx:BarChart id="barChart" width="100%" dataProvider="{ac}">
<mx:verticalAxis>
<mx:CategoryAxis dataProvider="{ac}" categoryField="label"/>
</mx:verticalAxis>
<mx:series>
<mx:BarSeries xField="val" labelPosition="outside"/>
</mx:series>
</mx:BarChart>
EDIT: Is this a bug in Flex and (therefore) unanswerable?
Seems to me that this is a problem of size, with 22 bars the label are too small to see, so they don't show. if you change the range of the "for" to:
for(var k:int=-5; k<5; k++)
you should be able to see all the labels of the chart.
精彩评论