legend

Specifies PieChart legend options.

Type: Object

The PieChart widget can include a legend. It helps you distinguish and identify the points of the displayed series. Each point is presented by an item on the legend. An item marker identifies the point's (slice's) color. An item label displays a value corresponding to the point. Use the legend property to set up PieChart legend options to the required values. To learn more about the legend and its options, refer to the Legend topic.

Show Example:
jQuery

In this example, the legend's horizontalAlignment and verticalAlignment options are changed.


                                    

                                    

backgroundColor

Specifies a color for the legend's background.

Type: String
Default Value: undefined

Show Example:
jQuery

In this example, the legend's backgroundColor option is set to lightyellow.


                                    

                                    

border

Specifies legend border options.

Type: Object

Use this object to make a legend's border visible/invisible and set up such border options as color, width etc.

Show Example:
jQuery

This example shows how to customize the appearance of the legend border.


                                    

                                    

columnCount

Specifies how many columns it takes to arrange legend items.

Type: Number
Default Value: 0

To arrange legend items, specify how many rows and columns they must occupy. To do this, use the rowCount and columnCount properties.

Show Example:
jQuery

In this example, the legend items are displayed in 2 columns.


                                    

                                    

columnItemSpacing

Specifies a blank space between legend columns in pixels.

Type: Number
Default Value: 8

Show Example:
jQuery

In this example, the legend items are displayed in 2 columns with 100 pixel spacing.


                                    

                                    

customizeHint

Specifies the text for a hint that appears when a user hovers the mouse pointer over a legend item.

Type: function(pointInfo)
Function parameters:
pointInfo: Object

Information on the point that corresponds to the legend item.

Object structure:
pointName: any

Specifies the name of the point argument for which the current legend item is created.

pointIndex: Number

Specifies the index of the point for which the current legend item is created.

pointColor: String

Specifies the color of the point for which the current legend item is created.

Return Value: String

The text to be displayed in a hint for a legend item.

This option accepts a function that must return the required text. When implementing this function, use its parameter to access the information on the point that corresponds to the legend item.

customizeText

Specifies a callback function that returns the text to be displayed by a legend item.

Type: function(pointInfo)
Function parameters:
pointInfo: Object

Information about the point to be presented in the legend.

Object structure:
pointName: any

Specifies the name of the point argument for which the current legend item is created.

pointIndex: Number

Specifies the index of the point for which the current legend item is created.

pointColor: String

Specifies the color of the point for which the current legend item is created.

Return Value: String

The text to be displayed by a legend item.

Cannot be used in themes.

By default, legend items identify chart points (sectors) by color and argument name. You can also provide other information instead of the point argument name. To do this, implement a callback function for this property, and return the required text. Use the fields of the object passed as the function's parameter in the returned text. For instance, you can use the point argument name or index if it is more appropriate in your case.

Alternatively, you can use the this object within the function. This object has the same structure as the object passed as a parameter.

font

Specifies font options for the text displayed in the legend.

Type: Object

Show Example:
jQuery

In this example, the legend item text's font options are changed.


                                    

                                    

horizontalAlignment

Specifies a legend's position on the chart.

Type: String
Default Value: 'right'
Accepted Values: 'right' | 'center' | 'left'

When configuring the widget using ASP.NET MVC Wrappers, specify this option using the HorizontalAlignment enum. This enum accepts the following values: Left, Center and Right.

Show Example:
jQuery

Use the drop-down list below to change the legend's horizontalAlignment option.


                                    

                                    

hoverMode

Specifies what chart elements to highlight when a corresponding item in the legend is hovered over.

Type: String
Default Value: 'allArgumentPoints'
Accepted Values: 'allArgumentPoints' | 'none'

In the PieChart widget, legend items represent series points. When a legend item is hovered over, the corresponding series point is highlighted. To prevent this behavior, set the hoverMode property to 'none'.

You can set a custom 'hover' style for series points. To do this, use the series | hoverStyle configuration object.

When configuring the widget using ASP.NET MVC Wrappers, specify this option using the ChartLegendHoverMode enum. This enum accepts the following values: AllArgumentPoints and None.

Show Example:
jQuery

Change the value of the legend's hoverMode option using the drop-down list below, and hover over one of the legend items to see the effect.


                                    

                                    

itemsAlignment

Specifies the alignment of legend items.

Type: String
Default Value: undefined
Accepted Values: 'right' | 'center' | 'left'

This option is useful when there is an odd count of items in the legend and they are placed in several columns.

When configuring the widget using ASP.NET MVC Wrappers, specify this option using the HorizontalAlignment enum. This enum accepts the following values: Left, Center and Right.

itemTextPosition

Specifies the position of text relative to the item marker.

Type: String
Default Value: undefined
Accepted Values: 'right' | 'left' | 'top' | 'bottom'

A legend item consists of a marker that indicates the series (for the **Chart** widget) / point (for the **PieChart** widget) color and text that specifies the name of the series/point. Use the itemTextPosition property to specify how the text should be positioned relative to the item marker.

Show Example:
jQuery

Use the drop-down list below to change the itemTextPosition option.


                                    

                                    

margin

Specifies the distance between the legend and surrounding widget elements or container borders in pixels.

Type: Number|Object
Default Value: 10

When this option is set to a number, the specified margin applies to all the sides of the legend. Alternatively, the margin option can be set to an object. This object specifies margins for each side of the legend separately.

Whether or not the specified margin is applied to a particular side of the legend depends on the legend's location. The location is determined by the horizontalAlignment and verticalAlignment options. Refer to the top, bottom, left and right options' description to discover when the margin applies to the corresponding side of the legend.

LegendMargin ChartJS

markerSize

Specifies the size of item markers in the legend in pixels.

Type: Number
Default Value: 20

Show Example:
jQuery

In this example, the size of the legend item markers is altered to 10.


                                    

                                    

orientation

Specifies whether to place legend items horizontally or vertically.

Type: String
Default Value: undefined
Accepted Values: 'vertical' | 'horizontal'

When this option is set to 'vertical', legend items are displayed vertically (i.e., in a column). When this option is set to 'horizontal', legend items are displayed horizontally (i.e, in a row). When this option is not defined, the legend orientation is chosen automatically.

When configuring the widget using ASP.NET MVC Wrappers, specify this option using the Orientation enum. This enum accepts the following values: Horizontal and Vertical.

Show Example:
jQuery

Use the drop-down list below to change the legend's horizontalAlignment option.


                                    

                                    

paddingLeftRight

Specifies a blank space between a legend's left/right boundaries and the inner item boundaries in pixels.

Type: Number
Default Value: 10

LegendPadding ChartJS

paddingTopBottom

Specifies a blank space between a legend's top/bottom boundaries and the inner item boundaries in pixels.

Type: Number
Default Value: 10

LegendPadding ChartJS

rowCount

Specifies how many rows it takes to arrange legend items.

Type: Number
Default Value: 0

To arrange legend items, specify how many rows and columns they must occupy. To do this, use the rowCount and columnCount properties.

Show Example:
jQuery

In this example, the legend items are displayed in 2 rows. In addition, the legend position on a chart is changed using the horizontalAlignment and veticalAlignment options, and the position of the legend item text is changed using the itemTextPosition option.


                                    

                                    

rowItemSpacing

Specifies a blank space between legend rows in pixels.

Type: Number
Default Value: 8

Show Example:
jQuery

In the example below, the legend items are displayed in 2 rows with 100-pixel spacing. In addition, the position of the legend is set using the horizontalAlignment and verticalAlignment options.


                                    

                                    

verticalAlignment

Specifies a legend's position on the chart.

Type: String
Default Value: 'top'
Accepted Values: 'top' | 'bottom'

When configuring the widget using ASP.NET MVC Wrappers, specify this option using the VerticalEdge enum. This enum accepts the following values: Top and Bottom.

Show Example:
jQuery

Use the drop-down list below to change the legend's verticalAlignment option.


                                    

                                    

visible

Specifies the visibility state of the chart's legend.

Type: Boolean
Default Value: true

Show Example:
jQuery

Use the check box at the bottom to change legend visibility.