Skip to content

Legend

Legends are used to display the values of each entry in a visualization. They are not enabled by default.

1
myChart.set('legend','right')

The value passed to the option can be a string, with the values 'none'  to hide it or 'right' to display it,or a Legend object with the following format:

1
2
3
4
5
6
var legend = cf.Legend()
                .position('right')
                .width(100)
                .height(200)
                .sort('none')
myChart.set('legend',legend)

The Legend() object may contain any or all the configuration values as shown in the code, except for the position(), the rest are optional. width() and height() are self explanatory and their values are numbers in pixels.

L1

sort() accepts 'none' or 'reverse' and it will re-order the items from the legend:

L2