Set the legend. The legend is a box containing a symbol and name for each series item or point item in the chart.

Method used

Parameters:

  • mixed $name: the option name for the legend. Can be a string or array. When used as array a key value pair should be defined, where the key is the name
  • mixed $mixvalue: a value option in case the name is a string

API Tags:
Return: instance
Access: public

Example:

... $chart = new jqChart(); $chart->setChartOptions(array( "defaultSeriesType"=>"bar" )) ->setLegend(array( "layout"=> 'vertical', "align"=> 'right', "verticalAlign"=> 'top', "x"=> -100, "y"=> 100, "floating"=> true, "borderWidth"=> 1, "backgroundColor"=> '#FFFFFF', "shadow"=>true )) ...


Option name Type Default
align String center
The horizontal alignment of the legend box within the chart area. Defaults to "center".
backgroundColor Color null
The background color of the legend, filling the rounded corner border. Defaults to null.
borderColor Color #909090
The color of the drawn border around the legend. Defaults to #909090.
borderRadius Number 5
The border corner radius of the legend. Defaults to 5.
borderWidth Number 1
The width of the drawn border around the legend
enabled Boolean true
Enable or disable the legend. Defaults to true.
floating Boolean false
When the legend is floating, the plot area ignores it and is allowed to be placed below it.
itemHiddenStyle Array array("color" =>'#CCC')
CSS styles for each legend item when the corresponding series or point is hidden. Properties are inherited from style unless overridden here.
itemHoverStyle Array array("color"=>'#000')
CSS styles for each legend item in hover mode. Properties are inherited from style unless overridden here.
itemStyle Array array("cursor"=>'pointer',"color"=>'#3E576F')
CSS styles for each legend item.
itemWidth Number null
The width for each legend item. This is useful in a horizontal layout with many items when you want the items to align verticall.
labelFormatter JS Function See below
Callback function to format each of the series' labels. The this keyword refers to the series object, or the point object in case of pie charts. Defaults to:
labelFormatter: function() { return this.name } When set a "js:" should be set before the string.
lineHeight Number 15
f the plot area sized is calculated automatically and the legend is not floating, the legend margin is the space between the legend and the axis labels or plot area.
reversed Boolean false
Whether to reverse the order of the legend items compared to the order of the series or points as defined in the configuration object
shadow Boolean false
Whether to apply a drop shadow to the legend. A backgroundColor also needs to be applied for this to take effect.
style Array
CSS styles for the legend area.
symbolPadding Number 5
The pixel padding between the legend item symbol and the legend item text
symbolWidth Number 30
The pixel width of the legend item symbol
verticalAlign String "bottom"
The vertical alignment of the legend box. Can be one of "top", "middle" or "bottom". Vertical position can be further determined by the "y" option.
width Number null
The width of the legend box, not including style.padding
x Number 15
The x offset of the legend relative to it's horizontal alignment align within chart.spacingLeft and chart.spacingRight. Negative x moves it to the left, positive x moves it to the right. The default value of 15 together with align: "center" puts it in the center of the plot area.
y Number 0
The vertical offset of the legend relative to it's vertical alignment verticalAlign within chart.spacingTop and chart.spacingBottom. Negative y moves it up, positive y moves it down.