Hello,
I am using a ColorGrid series and GridPalette entries to show a plot of color codes. To have the legend show the description for each color, I use the LegendStyle.Palette and handle the GetLegendText event.
Now, my problem is that I have a hard time matching the description text with the correct color. In the GetLegentText event handler I use the Index member of the GetLegendTextEventArgs argument, but as far as I can see the index does not correspond to the order in which I added the palette entries to the ColorGrid series:
// Setup palette...
_seriesColorGrid.Palette.Clear();
_seriesColorGrid.Palette.Add( new GridPalette( 0.0f, Color.Magenta ) );
_seriesColorGrid.Palette.Add( new GridPalette( 1.0f, Color.Blue ) );
_seriesColorGrid.Palette.Add( new GridPalette( 2.0f, Color.Green ) );
_seriesColorGrid.Palette.Add( new GridPalette( 3.0f, Color.Red ) );
_seriesColorGrid.Palette.Add( new GridPalette( 4.0f, Color.Yellow ) );
...
// The GetLegendText event handler...
private void _chart_GetLegendText( object sender, GetLegendTextEventArgs e )
{
e.Text = _resourceManager.GetString( "FlowReg" + e.Index.ToString() );
}
In the GetLegendText event handler I assumed that e.Index = 0 would indicate the first GridPalette entry (color = Magenta), but it seems to actually indicate the last entry (color = Yellow). As I investigated further it seemed that the indexes I get in the event handler matches my color entries in reverse order.
My questions are: Is this by design, or is it just a coincidence? Am I handling the indexes/colors in an unsafe way? Should I take a whole new approach, or is it safe to simply do "FlowReg" + (NumPaletteEntries-e.Index-1).ToString() instead?
Regards
Steffen Skov
Senior Consultant
SPTGroup
ColorGrid, GridPalette and GetLegendText event
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Steffen,
This is by design. Unless you are changing which items are displayed in the legend it seems fine to me. I would try using the approach you suggest.
Code: Select all
My questions are: Is this by design, or is it just a coincidence? Am I handling the indexes/colors in an unsafe way? Should I take a whole new approach, or is it safe to simply do "FlowReg" + (NumPaletteEntries-e.Index-1).ToString() instead?
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |