Legend

A legend is a chart element that is used to display the series name of each dataset in multi-series/combination charts. Legends are not applicable to single series charts. Legends are used to correlate a data plot to its series name using its color.

In the chart below - notice the legend below the x-axis which helps identify the series name.

Configuring Your Chart - Legend

Starting FusionCharts Suite XT v3.4, each series is represented by it’s own icon in the legend.

In FusionCharts Suite XT, legends are interactive by default. Each legend icon when clicked, shows or hides the dataset series corresponding to that item.

This article talks about:

  • Setting legend position

  • Configuring legend icon size

  • Customizing legend scroll bar

  • Reversing legend order

  • Hiding legend

  • Hiding series upon loading

  • Customizing legend appearance

  • Customizable legend font cosmetics

Setting legend position

A multi-series column 2D chart with legend position changed to right looks as below:

FusionCharts should load here..

The attribute to set legend position is as mentioned below.

Attribute Name Description
legendPosition The legend can be plotted at two positions on the chart - below the chart for value bottom and to the right of the chart for value right.
legendAllowDrag The legend can be made drag-able by setting this attribute to 1. Set this to 0 (default) to disable dragging.

The data structure needed to change legend position in a chart is given below:

...

Configuring legend icon size

A multi-series column 2D chart with legend icon size changed to '2' looks as below:

FusionCharts should load here..

The attribute to configure legend icon size is detailed below:

Attribute Name Description
legendIconScale Scaling of legend icon is possible in FusionCharts XT. This attribute lets you control the size of legend icon with valid values from 1 (100%) to 5 (500%).

The data used, in the chart above, to change legend icon size in a chart is as given below:

...

Customizing legend scroll bar

If you have multiple data items in a multi-series chart, the legend automatically displays a scroll bar.

A multi-series column 2D chart with customized cosmetic properties of the legend scroll bar looks as below:

FusionCharts should load here..

The list of the attributes used to customize cosmetic properties of the legend scroll bar is mentioned below:

Attribute Name Description
legendScrollBgColor Sets the background color of the scroll bar. Accepts hex code. e.g. #00ffaa.

The data structure needed to customize the cosmetic properties of the legend scroll bar is given below:

...

Reversing legend order

A multi-series column 2D chart with the order of legend items reversed looks as below:

FusionCharts should load here..

The attribute to reverse legend order is mentioned below:

Attribute Name Description
reverseLegend You can reverse the ordering of datasets in the legend by setting this attribute to 1. This is set to 0 by default.

The data structure needed to reverse the order of legend items is given below:

...

Hiding legend

A multi-series column 2D chart with legend hidden looks as below:

FusionCharts should load here..

The attribute to show or hide a legend is mentioned in the table below:

Attribute Name Description
showLegend Whether to show legend on the chart. Set it to 1 to show the legend or to 0 to hide it.

The data structure needed to hide a legend is given below:

...

Hiding series upon loading

A multi-series column 2D chart with one data series hidden looks as below:

FusionCharts should load here..

Given below is the attribute used to initially hide a dataset on chart loading:

Attribute Name Description
initiallyHidden Works from the dataset object level in JSON data. Set it to 1 to hide the plots of a series initially, on chart load. Default value is 0 for all series and they show up initially.

The data structure needed to hide a series is given below:

...

Customizing legend appearance

A multi-series column 2D chart legend with customized appearance looks as below:

FusionCharts should load here..

Given below is the list of attributes used to customize the legend appearance:

Attribute Name Description
legendBgColor Background color for the legend. Accepts hex code. e.g. #00ffaa.
legendBgAlpha Background alpha for the legend. It can take values from 0 (transparent) to 100 (opaque).
legendBorderColor Border Color for the legend. Accepts hex code. e.g. #00ffaa.
legendBorderThickness Border thickness for the legend (in pixels).
legendBorderAlpha Border alpha for the legend. It can take values from 0(transparent) to 100 (opaque).
legendShadow Whether to show a shadow for legend. Set it to 1 to show shadow and 0 to hide it.
legendScrollBgColor If you've too many items on the legend, a scroll bar shows up on the same. This attribute lets you configure the background color of the scroll bar. Accepts hex code. e.g. #00ffaa.
legendCaptionAlignment Sets the legend caption horizontal alignment with valid values of left, center and right.

The data structure needed to customize the legend appearance is given below:

...

Customizing legend font cosmetics

A multi-series column 2D chart legend with customized font cosmetics looks as below:

FusionCharts should load here..

Given below is the list of attributes used to customize the legend font cosmetics:

Attribute Name Description
legendItemFont Sets legend item font, e.g. Arial
legendItemFontSize Sets legend item font size, with values ranging from 0 to 72
legendItemFontColor Sets legend item font color in hex code, e.g. #00ffaa
legendItemFontBold Whether legend keys should be displayed in bold. Set 1 to make it bold or 0 to keep it normal.
legendItemHoverFontColor Sets legend item font color on hover in hex code, e.g. #00ffaa
legendCaptionFont Sets legend caption font, e.g. Arial
legendCaptionFontSize Sets legend caption font size, with values ranging from 0 to 72
legendCaptionBold Whether legend caption should be displayed in bold. Set 1 to make it bold or 0 to keep it normal.

The data structure needed to customized legend font cosmetics is given below:

...