Hi Oliver. That's correct...there's no built in way to tell the chart to
style a particular 'row' of the data differently. Rather than trying to
access and modify a renderer directly, you'll have to somehow provide
the information your particular application needs as an input to your
custom renderer.
 
There's a couple of ways you can achieve this effect:
 
 
1) embed all the data necessary to determine the rendering in the data
itself.  An example of this might be threshold rendering.  i.e., if your
data is greater than 100, it renders green, otherwise it renders red.  A
slightly clunkier version would be to add a field to your dataset called
'color.' Your custom renderer can look at this field and use it to
decide what color to render its particular box.
 
2) use globals. You could define a static variable on your renderer that
it uses as input to its rendering.  An example would be
selection...define a static variable called 'selectedIndex' which
indicates which column is selected. When a renderer goes to render
itself, it would look at its index, and this global variable, and
chooses a color based on whether they match. This clearly wouldn't work
if you're going to have multiple charts on screen using your custom
renderer at once, but it's a quick and dirty solution.
 
3) extend your series class to manage additional data needed by your
renderer.  The renderer has access to the series it is part of...you can
have your renderer look at your series for a property that contains
additional information (like the selection example). This approach
avoids the singleton issues of option 2.
 
4) add addtional data to your series as a style from actionscript. Your
renderers inherit all of the styles assigned to the series they are part
of.  In actionscript, you can assign data to arbitrary styles on your
series...something like:
 
myChart.series[0].setStyle("itemsThatAreSelected",[1,5,13,28]);
 
and then retrieve those values in your renderer when
rendering...something like:
 
function updateDisplayList(....):void
{
  var selectedIndices:Array = getStyle("itemsThatAreSelected");
}
 
The rules of MXML mean you can't declare those styles on the series in
MXML (since the series component doesn't declare the style in metadata),
but there's nothing stopping you from adding them in actionscript.
 
5) add the logic to the series by writing a custom one (or extending a
built in one), not the renderer. The cleanest but most difficult
approach would be to add additional logic to the series itself.  The
series could choose to use differenet renderers for different columns,
change their alpha, etc.
 
 
In the end though, it's up to you to know that you want to make a change
to the first renderer in each of your stacked series, and make sure that
the solution you choose addresses all of them.
 
 
Ely.
 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of oliver langan
Sent: Wednesday, November 15, 2006 4:16 PM
To: [email protected]
Subject: [flexcoders] Re: Setting alpha style on a single stacked column



--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Ely Greenfield" <[EMAIL PROTECTED]> wrote:
> Oliver...my answer to you would be essentially the same as my answer
to
> Tom earlier in the conversation. You'll need to write a custom
renderer
> for each series in your stack if you want to render the first column
> differently. The default charts assume that the renderers are there to
> represent the state of the underlying data...since renderers are
created
> and destroyed dynamically as needed as the data changes, reaching into
> the chart to try and modify individual renderers is shaky at best...if
> you're making a change that isn't either a change to the inputs to the
> chart (i.e., the data) or the logic of the chart (i.e., the rendering
> algorithm of the renderers), there's no guarantee as to how long your
> modification would apply.
> 
> Ely.

I think I understand what you are saying, but it still does not make
complete sense vis-a-vis my experience with stacked charts. In fact,
I am using a custom renderer in some of my charts, so I realize that I
can apply that separately for each series: but a stack represents
multiple (usually all) of the series together as a single visual item
(stacked boxes). What does not seem possible is to apply styles to a
single set of the data in the chart (effectively one 'row' of data).

BTW, I made a mistake earlier when I said I could get to the
individual 'box' element drawn for a chart item. While this might be
possible, what I am actually doing is dynamically changing the style
on the ColumnSeries. The effect of this is shared across all of the
data elements in each stack which are part of that series, but in this
case I have a single stacked column so I am able to use it as a
highlight effect.

oliver



 

Reply via email to