Hi,

If you need to change the appearance of a chart item conditionally,
based upon data values, you can use a barRenderer (or wedgeRenderer; a
little confused which chart type you're using).    To access the data
associated with the chart item, (per Ely's suggestion a while back)
Implement IDataRenderer.  Here's a sample.  Sorry that the formatting
doesn't paste.

-TH

package com.myNamespace
{
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;

  public class SampleBarRenderer extends ProgrammaticSkin implements
IDataRenderer
  {
   private var _chartItem:ChartItem;
   private static const fills:Array = [0xCCCCCC,0x00FFFF];

   public function SampleBarRenderer():void
   {
    super();
   }

   public function get data():Object
   {
    return _chartItem;
   }

   public function set data(value:Object):void
   {
    if (_chartItem == value) return;

    _chartItem = ChartItem(value);
   }

   override protected function updateDisplayList(unscaledWidth:Number,
                unscaledHeight:Number):void
   {
    super.updateDisplayList(unscaledWidth, unscaledHeight);

    var fill:Number;

    if (_chartItem != null)
    {
     if (_chartItem.CategoryField.toString() == "myRedCondition")
     {
      fill = fills[1];
     }
     else
     {
      fill = fills[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();
   }
  }
}

--- In [email protected], "alok356" <[EMAIL PROTECTED]> wrote:
>
> Hi
> For Flex charts
> I need a way to say the char data item color based on the data of item
> Simply all bars are gray, and ones with data exceeding a threshold
red.
>
> How can I do that, I understand, I need write some custom Item
> renderer. Still not sure about it. Can I extend the
> WedgeItemRenderer and some provide a fill depending on the data, could
> not find a way to do that.
>
> Thanks
> alok
>



Reply via email to