skip to main content
Gantt > Programmer's documentation > Developing with the JViews Charts SDK > Handling chart renderers > Legend items
 
Legend items
By default, all the visible renderers with the visibleInLegend property set to true drawn in a chart appear in the chart legend (if a legend exists) as labelled symbols. The legend item that represents the renderer is an instance of the IlvRendererLegendItem class, an IlvLegendItem subclass that works with the chart renderer. The purpose of this class is to delegate the legend item drawing operation to the associated renderer, so that the legend item symbol is drawn according to the renderer type and its current rendering style.
This delegation affects both the item symbol and the label, and is handled at the chart renderer level by the following methods:
*getLegendText
Returns the text to display next to the symbol. The default implementation returns the name of the renderer or, in the case of a single renderer, the name of the data set if the renderer name is null.
*getLegendStyle
Returns the rendering style used to draw the symbol. The default implementation returns the first style contained in the styles property.
*drawLegendSymbol
Draws the legend item symbol. This method is automatically called by the renderer legend item when it is drawn.
The renderer legend items are automatically created by the chart renderer when it is added to a chart, provided that an IlvLegend object has been set. The items creation is performed by the createLegendItems abstract method, which returns an array of legend items associated with a renderer. Being abstract, the implementation highly depends on the renderer type, but the general rule is:
*A single renderer creates one IlvRendererLegendItem instance.
A simple composite renderer creates one IlvRendererLegendItem instance for each single child renderer it references.

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.