Hi Amy, I guess that everyone has their own perspective. Like you, I used to complain that the flex styles weren't as comprehensive as the .net controls that I was used to at the time. However, looking at it from an 80-20 point of view, the basics are there; especially for charts. The point is that I'll gladly sacrifice some built-in properties, if the framework supports rolling my own components and/or extending; to customize properties. Sometimes, it takes more time and effort to complain about something, than it does to just create it yourself. Here's a solution that took very little time to create:
Best Regards, -TH <?xml version="1.0"?> <!-- charts/BasicBar.mxml --> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script><![CDATA[ import mx.collections.ArrayCollection; [Bindable] public var expenses:ArrayCollection = new ArrayCollection([ {Month:"Jan", Profit:2000, Expenses:1500}, {Month:"Feb", Profit:1000, Expenses:200}, {Month:"Mar", Profit:1500, Expenses:500} ]); ]]></mx:Script> <mx:Panel title="Bar Chart"> <mx:BarChart id="myChart" dataProvider="{expenses}" showDataTips="true"> <mx:verticalAxis> <mx:CategoryAxis dataProvider="{expenses}" categoryField="Month"/> </mx:verticalAxis> <mx:series> <mx:BarSeries yField="Month" xField="Profit" displayName="Profit" labelPosition="none" itemRenderer="LabeledRenderer" fills="[0x984EA3,0x4DAF4A,0x377DB8]" color="#000000"/> </mx:series> </mx:BarChart> </mx:Panel> </mx:Application> _______________________________________________________________ Renderer _______________________________________________________________ package { import flash.display.Graphics; import flash.geom.Rectangle; import mx.charts.ChartItem; import mx.charts.chartClasses.GraphicsUtilities; import mx.core.IDataRenderer; import mx.graphics.IFill; import mx.graphics.IStroke; import mx.skins.ProgrammaticSkin; import mx.controls.Label; import mx.core.UIComponent; import mx.charts.BarChart; import mx.charts.series.items.BarSeriesItem; public class LabeledRenderer extends UIComponent implements IDataRenderer { private var _label:Label; public function LabeledRenderer():void { super(); _label = new Label(); addChild(_label); _label.setStyle("color",getStyle("color")); } private var _chartItem:ChartItem; public function get data():Object{ return _chartItem; } public function set data(value:Object):void { if (_chartItem == value) return; _chartItem = ChartItem(value); if(_chartItem != null) _label.text = BarSeriesItem(_chartItem).xValue.toString(); } private static var fills:Array = []; override protected function updateDisplayList(unscaledWidth:Number,unscaledHeight:Number):void{ super.updateDisplayList(unscaledWidth, unscaledHeight); fills = getStyle("fills"); var fill:Number = (_chartItem == null)? 0:fills[_chartItem.index % fills.length]; var rc:Rectangle = new Rectangle(0, 0, width , height ); var g:Graphics = graphics; g.clear(); g.moveTo(rc.left,rc.top); g.beginFill(fill); g.lineTo(rc.right,rc.top); g.lineTo(rc.right,rc.bottom); g.lineTo(rc.left,rc.bottom); g.lineTo(rc.left,rc.top); g.endFill(); _label.setActualSize(_label.getExplicitOrMeasuredWidth(),_label.getExpli\ citOrMeasuredHeight()); _label.move(unscaledWidth/2 - _label.getExplicitOrMeasuredWidth()/2, unscaledHeight/2 - _label.getExplicitOrMeasuredHeight()/2); } } } --- In flexcoders@yahoogroups.com, "Amy" <[EMAIL PROTECTED]> wrote: > > --- In flexcoders@yahoogroups.com, "Tim Hoff" TimHoff@ wrote: > > > > > > Ok, so we're talking about a vertical axis. . > > > > * For a vertical axis, by default the labels are vertically > aligned > > to the tick marks (center). For these, you can adjust the label > > position (up/down) slightly with the labelAlign property; on the > axis > > tag. This still might not get you what you want though. Hard to > tell > > without seeing an image. > > * For a horizontal axis, use the labelGap property on the axis > tag to > > move the label down; from the axis line. > > * And, of course, you can always create your own axisRenderer. > This > > can get a little dicey though. > > > > I'd try labelAlign before moving on to creating a custom > axisRenderer. I > > agree, the chart framework is a substantial step in a positive > > direction. I think that Ely put it nicely here: > > No, I am talking about the labels WITHIN the bar. I've posted a > graphic here, since the ascii art got mangled despite my best > efforts: http://www.magnoliamultimedia.com/images/labels.jpg. This > is the BarSeries, not the Axis. In Eli's chart explorer, he does this > with a custom renderer, but it seems to me that it shouldn't be > necessary...why would the team choose an ugly alignment for the > default and give you no way to change it? > > I've seen places on people's blogs and even in the Flex 3 Cookbook > where people used bunches of code to do something you could do with > CSS or a property on the control, so just because there is an example > on someone's website (no matter how respected) that solves a problem > with a custom renderer, that doesn't mean that the custom renderer is > the only or even the best way to solve the problem. > > Thanks; > > Amy >