Dundas Chart for ASP.NET
CustomizeLegend Event
See Also  Example Send comments on this topic.
Dundas.Charting.WebControl Namespace > Chart Class : CustomizeLegend Event


This event fires just prior to the chart legend being drawn.
Fires just before the chart legend is drawn. Use this event to customize the chart legend items.

Syntax

Visual Basic (Declaration)  
Public Event CustomizeLegend() As CustomizeLegendEventHandler
Visual Basic (Usage) Copy Code
Dim instance As Chart
Dim handler As CustomizeLegendEventHandler
 
AddHandler instance.CustomizeLegend, handler
C#  
public event CustomizeLegendEventHandler CustomizeLegend()

Event Data

The event handler receives an argument of type CustomizeLegendEventArgs containing data related to this event. The following CustomizeLegendEventArgs properties provide information specific to this event.

Property Description
LegendItems

Enterprise Only Feature. Can be used to remove, modify, and change the order of both custom and default legend items. Custom items can also be added to the legend.


Legend items collection.
LegendName

Enterprise Only Feature. Gets the name of the Legend object, which can be used to determine which legend was the sender of the CustomizeLegendEvent.


Legend name.

Example

The following sample changes the symbol color of the "Sales" series' legend item to red.
Visual Basic Copy Code
Imports Dundas.Charting.WebControl<CRLF>...<CRLF><CRLF>Private Sub Chart1_CustomizeLegend(ByVal chart As Chart, ByVal e As CustomizeLegendEventArgs) _<CRLF>Handles Chart1.CustomizeLegend<CRLF><CRLF> 'declare a LegendItem object<CRLF> Dim legendItem As LegendItem<CRLF> <CRLF> For Each legendItem In e.LegendItems<CRLF> If legendItem.SeriesName = "Sales" Then<CRLF> legendItem.Color = Color.Red<CRLF> End If<CRLF> Next<CRLF> <CRLF>End Sub

Remarks

The CustomizeLegend event is primarily used to customize the legend just prior to being drawn. Both default and custom legend items can be removed or modified, and custom items can also be added. In addition the order of legend items can be changed.

The chart image can also be modified before being drawn using the sender argument.

Note that a "default" legend item is an item that is created for either a data series or data point, while a "custom" legend item is not connected in any way to the chart's data. For an explanation of "default" versus "custom" legend items see the Default and Legend Items and Custom Legend Items topics.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

Copyright © 2001 - 2009 Dundas Data Visualization, Inc. and others.