I'm having a problem with a similar itemRenderer. I based my custom
itemRenderer for my plotChart off of the one shown at
quietlyscheming... with the addition of sizing the item based on one
value in the dataProvider, and making the item visible based on another.
So in my dataProvider:
xAxis:Int controls the position on x
yAxis:Int controls the position on y
iSize:Int controls the size of the item
iVis:Boolean controls the visibility.
When I initially load the chart, everything renders as expected based
on the data.
If I update the xAxis or yAxis in the dataProvider, the item moves as
expected in realtime.
The problem is, when I update the iSize or iVis in the dataProvider,
those item states do not update.
My set data function in the itemRenderer class looks like
public function set data(value:Object):void
{
if (_chartItem == value)
return;
_chartItem = ChartItem(value);
_itemVisible = false;
if(_chartItem != null){
_itemReturn = _chartItem.item.xAxis;
_itemQuality = _chartItem.item.yAxis;
var iSize=
searchAndReplace(_chartItem.item.iSize,"$","");
iSize=
searchAndReplace(_chartItem.item.iSize,",","");
_itemSize = 1;
if (int(iSize) > 250000){
_itemSize = 2;
}
if (int(iSize) > 500000){
_itemSize = 3;
}
if (int(iSize) > 750000){
_itemSize = 4;
}
if (int(iSize) > 999999){
_itemSize = 5;
}
if (String(_chartItem.item.iVis)=="True"){
_itemVisible = true;
}
_label.text = _chartItem.item.iName;
_status.text = String(_itemSize);
_itemFill = 0xFFA023;
if (_xAxis< 0 && __yAxis< 0){
_itemFill = 0xFF0000;
}
if (_xAxis>= 0 && _yAxis>= 0){
_itemFill = 0x26B417;
}
}
}
and then my updateDisplayList function looks like
override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
if (_itemVisible){
var fill:* = (_over)? 0x0000FF:_itemFill;
var stroke:IStroke = getStyle("stroke");
var w:Number = (_itemSize - 1) * 4;
rcFill.right = unscaledWidth;
rcFill.bottom = unscaledHeight;
var g:Graphics = graphics;
g.clear();
if (stroke)
stroke.apply(g);
if (fill is IFill)
fill.begin(g, rcFill);
else if (fill is Number)
g.beginFill(fill);
g.drawCircle( unscaledWidth / 2, unscaledHeight / 2,
unscaledWidth / 2 + w);
if (fill is IFill)
fill.end(g);
else if (fill is Number)
g.endFill();
_label.setActualSize(_label.getExplicitOrMeasuredWidth(),_label.getExplicitOrMeasuredHeight());
_label.move(unscaledWidth/2 -
_label.getExplicitOrMeasuredWidth()/2,- (15 + w));
}
}
it seems like I'm not able to get the chart to fully redraw, even
calling invalidateDisplayList() and/or validateNow().
Anyone have any pointers as to how to get this to work?
Thanks in advance!
-Carl
--- In [email protected], "Lucas Pereira" <[EMAIL PROTECTED]> wrote:
>
> Hi. If you look at http://www.quietlyscheming.com/blog/charts/, you
> will find a lot of charting examples. One of then is a custom .as
> renderer that adds labels to a bar series. If you pick that example
> you can easily adopt it to a plot series. I've my self done a renderer
> that draws a colored dot and adds a label over it.
> Also take a look at
>
http://www.returnundefined.com/2006/11/creating-truly-reusable-renderers-with-classfactory/
> here you will find how to bind values into your custom renderer.
>
> I guess this is all you need to create a simple custom renderer in a
> plot chart.
>
> Cheers
> --- In [email protected], "supertodda" <todd@> wrote:
> >
> > Hello,
> >
> > Is there anybody out there that can give me an example of a custom
> > itemRenderer .as class for a Plot Chart? I've looked and cannot find
> > anyting that fits the bill. Simple is good, one that just draws a
> > circle and adds a tool tip would be appreciated.
> >
> > Thank you.
> >
>