In XtraCharts the Legend is a very versatile object allowing you a high degree of customization and interactivity.
Why Legends?
leg·end noun \ˈle-jənd\ (from Merriam-webster.com)
2c: an explanatory list of the symbols defined on a map or chart
The purpose of the legend is to help the viewer understand and quickly identify the items or series on a chart. I think that the Merriam-Webster definition of the word legend is a bit lagging. The truth is that legends can be used for a lot more today than Merriam-Webstar originally defined, especially because of the potential for interactivity provided with todays new charting platforms.
Legend Extras

In the image above instead of a line of text saying the name of the sales agent you see a picture of an agent with a colored border that corresponds to the bar. Optionally you could use any other image for your own legends, for example if you were comparing stocks, you could use corporate logos or if you were showing a chart of browser adoption on the internet you could use the logos for the respective browsers. Additionally legends can also be interactive, if you’re familiar with Hot Tracking (selecting a series on mouse over) you can also use hot tracking on the Legend items themselves. One of the benefits of this is clarity, if you have a lot of bars in a chart it may be easier to identify a series via the legend, so what you could do with that is use the legend as a way to select an item for drill down.
Take Advantage of your Legends
To take advantage of the more advanced features of legends there are a few events you need to become familiar with.
CustomDrawSeries
The first is the CustomDrawSeries event, it fires every time the chart is redrawn and is called for each series on the chart. The following table shows the properties used for handling the extended legend functionality.
| Property | Description |
| DisposeLegendFont | Gets or sets a value that specifies whether the CustomDrawSeriesEventArgs.LegendFont property value should be disposed when drawing is finished. |
| DisposeLegendMarkerImage | Gets or sets a value that specifies whether the CustomDrawSeriesEventArgs.LegendMarkerImage property value should be disposed when drawing is finished. |
| LegendDrawOptions | Gets the settings for custom drawing the legend. |
| LegendFont | Specifies the font of the legend marker text for the series whose points are currently being painted. |
| LegendMarkerImage | Specifies the legend marker image for the series whose points are currently being painted. |
| LegendMarkerImageSizeMode | Specifies the legend marker image size mode for the series whose points are currently being painted. |
| LegendMarkerSize | Specifies the legend marker size for the series whose points are currently being painted. |
| LegendMarkerVisible | Specifies the legend marker visibility for the series whose points are currently being painted. |
| LegendText | Specifies the legend's text for the series whose points are currently being painted. |
| LegendTextColor | Specifies the legend text color for the series whose points are currently being painted. |
| LegendTextVisible | Specifies the legend text visibility for the series whose points are currently being painted. |
Part of what the CustomDrawSeries event allows is the ability to place a custom image in the legend box. Beyond that there are methods for adjusting the size, color and text for legend items.
ObjectHotTracked
The second event to look at is the ObjectHotTracked event this event fires any time an item on the chart is hot tracked (hovered over). Note: HotTracking is only enabled if the RuntimeSelection property is set to true. The ObjectHotTracked event allows you to make the objects interactive so that when the series items are hovered you can change how the series or the legend items are drawn.
ObjectSelected
The last event to be familiar with is the ObjectSelected this allows you to react to the selection of a series. Note: like HotTracking the ObjectSelected event is only enabled if the RuntimeSelection property is set to true.
Through the usage of the three events you can create some very complex behavior and interactions that will enable you to give your end users more information in a format that is easier to use and more discoverable.
Have you already extended Legends in your application? Drop me a comment and tell me how you take advantage of legends.