Showing LineSeriesGroup Line Colors Based on Colored Legend Selections

23 views
Skip to first unread message

Andy Piatt

unread,
Aug 22, 2011, 3:11:02 PM8/22/11
to ax...@googlegroups.com
I have a dynamically generated (from CSV) line chart and custom chart legend, and am running into troubles...

Background:

I have a set color palette that colors both the legend items and the lines that correspond to those legend items. My legend is based on the flex horizontal list and each list item is colored based on this palette (colors 0-# of items in the CSV). As items in the legend are clicked, the corresponding chart line is added/removed from the line series by means of a dataFilterFunction (I maintain a total items array, and an excluded items array). This dataFilterFunction then rebuilds a color palette of current colors that should be used for the remaining lines on the chart. Lastly, the Degrafa SolidStroke uses a colorFunction to iterate through that current color palette assigning colors to each line being displayed, corresponding to the legend items selected for display. I would love to have used the autopalette, but the legend needs to be static in its coloring, and the lines need to match those legend colors.

Problem:

This works great for SOME situations. My initial display colors are off just a bit, but making my first selection from the legend corrects this. When ALL items are selected in the legend (all lines displayed) all lines display as black (the degrafa default). When TWO legend items are selected, both lines display using the first of the two colors returned in the SolidStroke colorFunction. When any other number of legend items are selected, the line colors work perfectly (1, 3, 4, 5 ... n-1). I have a trace function in place to verify that the appropriate hex colors are being returned, and it appears that they are all being properly returned upon request by the SolidStroke colorFunction, so I am kind of at a loss at this point.

Other Info:

The color palette we are using is designed to be color-blind friendly, avoiding colors that could be confused by most of the leading types of color-blindness (found in 5%-9% of men). We would like to continue to use this palette, but I am certainly open to other (auto-generated palette) solutions.

I am using the Axiis and Degrafa SWC files distributed in the Axiis_Examples_Beta_1.0.zip dated Nov 2009 for use with Flex SDK 3.4 (which I am also using for this project).


Any suggestions, ideas, examples, or other approaches would be greatly appreciated!

taipan

unread,
Aug 29, 2011, 9:37:51 PM8/29/11
to Axiis
Eventually answered my own question...

I didn't realize the colorFunction used by degrafa:SolidStroke called
for color values for each line SECTION. The returned colors need to
change based on an event that is generated by the autoPalette, so I
needed to be able to get that event (or at least get a value that was
set by that event).

I ended up adding a customized version of LayoutAutoPalette, returning
the _layout.currentIndex value to get the correct color from my array,
and making the currentColor setable. I am now using this customized
version to generate my line color index and set my marker colors
accordingly.

Now I can use my own palette, based on the currently selected legend
items, and ensure my line colors correspond.
Reply all
Reply to author
Forward
0 new messages