Barry,
Try grabbing the following inside the setter on the data property below...
it should represent the default fill color being applied. I've had this
work on ColumnSeries using custom itemRenderers.
value.element.getStyle("fill").color
Brendan
On 8/31/07, barry.beattie <[EMAIL PROTECTED]> wrote:
>
> can an itemRenderer work across a whole BarSet?
>
> I'm using Ely's ChartSampler app to try and come up with a bar chart
> where the values are labels inside each bar. it's adapting a couple of
> ideas in the ChartSampler. however, I'm tripping over some fundamental
> itemRenderer issues.
>
> I'm turning this:
> -------------------------------
> <BarChart id="chart" width="100%" height="100%"
> dataProvider="{dataSet.Sample}">
> <series>
> <BarSeries xField="revenue"
> itemRenderer="examples.customizing.LabeledRenderer"/>
> </series>
> <verticalAxis>
> <CategoryAxis categoryField="month" />
> </verticalAxis>
> </BarChart>
> -------------------------------
>
> to this to try and get each sub-bar to have the values for labels.
>
> -------------------------------
> <BarChart id="chart" width="100%" height="100%"
> dataProvider="{dataSet.Sample}">
> <series>
> <BarSet type="stacked">
> <BarSeries xField="costs"
> itemRenderer="examples.customizing.LabeledRenderer2" />
> <BarSeries xField="overhead"
> itemRenderer="examples.customizing.LabeledRenderer2" />
> <BarSeries xField="oneTime"
> itemRenderer="examples.customizing.LabeledRenderer2" />
> </BarSet>
> </series>
> <verticalAxis>
> <CategoryAxis categoryField="month" />
> </verticalAxis>
> </BarChart>
> -------------------------------
>
> which gives me the values as labels but does not rotate the fill
> colours and also gives me progressive totals, not individual sub-bar
> values.
>
> I can see why: a single itemRenderer only works with it's associated
> series for the label placement BUT works across the whole BarSet for
> the fill colours. By using it on each BarSeries I'm resetting the fill
> colour but also getting a progressive value of the series at each
> sub-bar (instead of descrete values)
>
> What I really need is for the itemrenderer to work across all the
> BarSet uniformly so it can apply the value label to each sub-bar and
> rotate the fill colours (adjusting the label colour to match)
>
> any suggestions how?
>
> thanx
> barry.b
>
> the itemRenderer used:
> -----------------------------
>
> package examples.customizing
> {
>
> 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 LabeledRenderer2 extends UIComponent implements IDataRenderer
> {
> private var _label:Label;
>
> public function LabeledRenderer2():void
> {
> super();
> _label = new Label();
> addChild(_label);
> _label.setStyle("color",0xFFFFFF);
> }
> private var _chartItem:ChartItem;
>
> public function get data():Object
> {
> return _chartItem;
> }
>
> public function set data(value:Object):void
> {
> if (_chartItem == value)
> return; // value already set, exit
> _chartItem = ChartItem(value); // else set the value
>
> if(_chartItem != null)
> _label.text = BarSeriesItem(_chartItem).xValue.toString();
> }
>
> private static const fills:Array = [0xFF0000,0x00FF00,0x0000FF,
> 0x00FFFF,0xFF00FF,0xFFFF00,
> 0xAAFFAA,0xFFAAAA,0xAAAAFF];
> override protected function updateDisplayList(unscaledWidth:Number,
> unscaledHeight:Number):void
> {
> super.updateDisplayList(unscaledWidth, unscaledHeight);
>
> var fill:Number = 0;
>
>
> 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.getExplicitOrMeasuredHeight());
> _label.move(unscaledWidth - _label.getExplicitOrMeasuredWidth(),
> unscaledHeight/2 - _label.getExplicitOrMeasuredHeight()/2);
> }
>
> }
>
> }
>
>
>
--
Brendan Meutzner
http://www.meutzner.com/blog/