new LegendOptions()
The LegendOptions object defines the configuration options to display the view's legend (the legend helps you choose which series to show or hide at runtime). The legend field of the Graph.Options object is used to configure the behavior and appearance of the chart's legend. It allows showing or hiding the legend, controlling the alignment of the legend's content, determining the flow of legend items, specifying text formatting for labels, defining grid layout, setting fixed dimensions for labels, locking the legend to prevent changes, adjusting padding between symbols and labels, reversing item order, and customizing symbol alignment and size. The LegendOptions object provides a comprehensive set of options to tailor the legend's presentation and functionality according to your specific requirements.
For instance, the "visible" option:
legend: { visible: true }shows the legend
Members
(static) align :Graph.LegendAlignEnum
The align field specifies the alignment of the legend's content. The legend is a panel that displays the series names along with their corresponding symbols, allowing users to easily identify and differentiate between the various series in the chart. By default, the legend's content is centered (align is null). Setting the align field to "start" or exontrol.Graph.LegendAlignEnum.exStart or 0 {number} aligns the legend's content to the start (left or top side of the view), while setting it to "center" or exontrol.Graph.LegendAlignEnum.exCenter or 1 {number} centers the legend's content within the legend panel. The alignment of the legend's content is determined based on the flow field and the specified align configuration, allowing for a more customized and visually appealing layout of the legend items.
Type:
Example
null {null} or exontrol.Graph.LegendAlignEnum.exCenter or 1 {number}, by default, centers the legend's content
"start" {string} or exontrol.Graph.LegendAlignEnum.exStart or 0 {number}, the legend's content is aligned to the start (left or top side of the view)
align
(static) dock :Graph.PanelDockEnum
The dock field specifies the edge of the container the legend-window is anchored to. The legend is a panel that displays the series names along with their corresponding symbols, allowing users to easily identify and differentiate between the various series in the chart. By default, the legend is anchored to the bottom-side of the view (dock is null). Setting the dock field to "left", "right", "top" or "bottom" anchors the legend to the corresponding side of the view. The legend map is shown from top to bottom when the legend window is docked to the left or right side of the view.
Type:
Example
null {null}, by default, the legend is anchored to the bottom-side of the view
"left" {string} or exontrol.Graph.PanelDockEnum.exLeft or 3 {number}, the legend is docked to the left side of the control
dock
(static) flow :Graph.LegendFlowEnum
The flow field determines whether the legend objects are arranged from left to right or top to bottom. The legend is a panel that displays the series names along with their corresponding symbols, allowing users to easily identify and differentiate between the various series in the chart. By default, the legend objects are aligned left to right while the legend panel is anchored to the top or bottom side of the view. Otherwise, the legend objects are vertically arranged. Setting the flow field to "top" or exontrol.Graph.PanelDockEnum.exTopToBottom or 1 {number} indicates that the next legend object gets arranged to the bottom of the current legend object, creating a vertical flow of items within the legend.
Type:
Example
null {null} or exontrol.Graph.LegendFlowEnum.exLeftToRight or 0 {number}, by default, the legend objects are aligned left to right while the legend panel is anchored to the top or bottom side of the view. Otherwise, the legend objects are vertically arranged.
"top" {string} or exontrol.Graph.PanelDockEnum.exTopToBottom or 1 {number}, indicates that the next legend object gets arranged to the bottom of the current legend object
flow
(static) formatText :exontrol.DrawTextFormatEnum
The formatText field specifies the flags the labels use to display on the legend. The Serie.Name property defines the name of the serie to display on the legend. The formatText field supports a combination of flags that control the alignment, word-breaking, clipping, and ellipsis behavior of the labels displayed on the legend. By configuring these flags, you can customize how the labels are presented within the legend, ensuring they fit appropriately and are visually appealing based on your specific design requirements.
The exontrol.DrawTextFormatEnum type supports the following flags:
- exTextAlignTop (0x00), justifies the text to the top of the rectangle
- exTextAlignLeft (0x00), aligns text to the left
- exTextAlignCenter (0x01), centers text horizontally in the rectangle
- exTextAlignRight (0x02), aligns text to the right
- exTextAlignVCenter (0x04), centers text vertically
- exTextAlignBottom (0x08), justifies the text to the bottom of the rectangle.
- exTextAlignMask (0x0F), specifies the mask for text's alignment.
- exTextWordBreak (0x10), breaks words. Lines are automatically broken between words if a word would extend past the edge of the rectangle specified by the lpRect parameter. A carriage return-line feed sequence also breaks the line. If this is not specified, output is on one line.
- exTextSingleLine (0x20), displays text on a single line only. Carriage returns and line feeds do not break the line.
- exTextExpandTabs (0x40), expands tab characters. The default number of characters per tab is eight.
- exPlainText (0x80), treats the text as plain text.
- exTextNoClip (0x0100), draws without clipping.
- exHTMLTextNoColors (0x0200), ignores the
and tags. - exTextCalcRect (0x0400), determines the width and height of the text.
- exHTMLTextNoTags (0x0800), ignores all HTML tags.
- exTextPathEllipsis (0x4000), for displayed text, replaces characters in the middle of the string with ellipses so that the result fits in the specified rectangle. If the string contains backslash (\) characters, exTextPathEllipsis preserves as much as possible of the text after the last backslash.
- exTextEndEllipsis (0x8000), for displayed text, if the end of a string does not fit in the rectangle, it is truncated and ellipses are added. If a word that is not at the end of the string goes beyond the limits of the rectangle, it is truncated without ellipses.
- exTextWordEllipsis (0x040000), truncates any word that does not fit in the rectangle and adds ellipses.
Type:
- exontrol.DrawTextFormatEnum
Example
null {null}, by default, the label can display on multiple lines
"center,vcenter,single" {string} or exontrol.DrawTextFormatEnum.exTextAlignCenter | exontrol.DrawTextFormatEnum.exTextAlignVCenter | exontrol.DrawTextFormatEnum.exTextSingleLine {exontrol.DrawTextFormatEnum} or 0x105 {number}, centers the label on a single line
formatText
(static) grid :any
The grid field indicates the number of columns or rows that the legend divides its content into. The legend is a panel that displays the series names along with their corresponding symbols, allowing users to easily identify and differentiate between the various series in the chart. By default, the number of columns and rows is not defined (grid is null), so the legend objects are arranged for best fit. Setting the grid field allows you to specify a fixed number of columns or rows for the legend layout, providing a more structured and organized presentation of the legend items. The arrangement of legend objects is determined based on the flow field and the specified grid configuration.
The grid field can be any of the following:
- {number}, defines a number that specifies the number of columns to divide the legend
- {string}, defines a string of "columns x rows" type that defines the number of columns and / or rows to arrange the legend objects. The columns and rows can be omitted.
- {array}, indicates a two-elements array of [columns,rows] type that specifies the columns and / or rows to arrange the legend objects
Type:
- any
Example
null {null}, by default, the number of columns, rows is not defined, so the legend objects are arranged for best fit
"x2" {string} or [0,2] {array}, defines a maxium 2-rows arrangement
"3 x 2" {string} or [3,2] {array}, defines a maxium 3-columns or 2-rows arrangement
grid
(static) labelFixedHeight :number
The labelFixedHeight field indicates the fixed-height to display the labels. The label of each legend item is displayed in a rectangle with the specified fixed-height. If the label's text exceeds the fixed-height, it is truncated according to the formatText field of the LegendOptions object. By default, the labelFixedHeight field has no effect, and the height of the label is determined by its content. Setting the labelFixedHeight field to a specific value allows you to control the height of the labels within the legend, ensuring a consistent and organized appearance.
The shapes field defines the visual appearance of various parts of the control, as follows:
- "legendLabel", specifies the appearance of labels for series that are currently visible in the map legend
- "legendLabelHidden", specifies the appearance of labels for series that are currently hidden in the map legend
- "legendSymbol", specifies the appearance of symbols for series that are currently visible in the map legend
- "legendSymbolHidden", specifies the appearance of symbols for series that are currently hidden in the map legend
- "legendUnit", specifies the appearance of the legend unit (the client rectangle containing both the symbol and label) for visible series in the map legend
- "legendUnitHidden", specifies the appearance of the legend unit (the client rectangle containing both the symbol and label) for hidden series in the map legend
Type:
- number
Example
null {null}, no fixed-height is applied (by default, the labelFixedHeight has no effect)
0 {number}, hides the label (@since 5.2)
64 {number}, fixes the label on a 64-px tall rectangle
labelFixedHeight
(static) labelFixedWidth :number
The labelFixedWidth field indicates the fixed-width to display the labels. The label of each legend item is displayed in a rectangle with the specified fixed-width. If the label's text exceeds the fixed-width, it is truncated according to the formatText field of the LegendOptions object. By default, the labelFixedWidth field has no effect, and the width of the label is determined by its content. Setting the labelFixedWidth field to a specific value allows you to control the width of the labels within the legend, ensuring a consistent and organized appearance.
The shapes field defines the visual appearance of various parts of the control, as follows:
- "legendLabel", specifies the appearance of labels for series that are currently visible in the map legend
- "legendLabelHidden", specifies the appearance of labels for series that are currently hidden in the map legend
- "legendSymbol", specifies the appearance of symbols for series that are currently visible in the map legend
- "legendSymbolHidden", specifies the appearance of symbols for series that are currently hidden in the map legend
- "legendUnit", specifies the appearance of the legend unit (the client rectangle containing both the symbol and label) for visible series in the map legend
- "legendUnitHidden", specifies the appearance of the legend unit (the client rectangle containing both the symbol and label) for hidden series in the map legend
Type:
- number
Example
null {null}, no fixed-width is applied (by default, the labelFixedWidth has no effect)
0 {number}, hides the label (@since 5.2)
64 {number}, fixes the label on a 64-px wide rectangle
labelFixedWidth
(static) locked :boolean
The locked field indicates whether the legend is locked(protected) or unlocked. When the legend is locked, users cannot show or hide the series by clicking on the legend items. By default, the legend is unlocked (locked is null), allowing users to interact with the legend and toggle the visibility of series in the chart. Setting the locked field to true locks the legend, preventing users from showing or hiding series through the legend interface, while setting it to false unlocks the legend, enabling user interaction for controlling series visibility.
Type:
- boolean
Example
false {boolean}, unlocks the legend (can show or hide the serie)
true {boolean}, locks the legend (can't show or hide the serie)
locked
(static) pad :number|string|array
The pad field defines the legend's padding, which represents the space between the legend's symbol and its label. The value can be a single numeric value, which applies the same padding to both the horizontal and vertical directions, or it can be specified as "x,y" or [x,y] to define separate padding values for the horizontal and vertical size, where x specifies the horizontal padding and y specifies the vertical padding. The Serie.Name property defines the name of the serie to display on the legend. By default, the padding is set to [4,4], which means there is a 4-pixel space between the legend's symbol and its label in both horizontal and vertical directions. Setting the pad field to 0 removes all padding, while specifying a custom value allows you to adjust the spacing according to your design preferences.
The shapes field defines the visual appearance of various parts of the control, as follows:
- "legendLabel", specifies the appearance of labels for series that are currently visible in the map legend
- "legendLabelHidden", specifies the appearance of labels for series that are currently hidden in the map legend
- "legendSymbol", specifies the appearance of symbols for series that are currently visible in the map legend
- "legendSymbolHidden", specifies the appearance of symbols for series that are currently hidden in the map legend
- "legendUnit", specifies the appearance of the legend unit (the client rectangle containing both the symbol and label) for visible series in the map legend
- "legendUnitHidden", specifies the appearance of the legend unit (the client rectangle containing both the symbol and label) for hidden series in the map legend
Type:
- number | string | array
Example
null {null}, indicates that the default padding value of [4,4] is applied
0 {number}, indicates no padding
2 {number}, indicates a 2-pixels horizontal padding and 2-pixels vertical padding
"8,4" {string}, indicates 8-pixels horizontal padding and 4-pixels vertical padding
[8,4] {array}, indicates 8-pixels horizontal padding and 4-pixels vertical padding
pad
(static) reverse :boolean
The reverse field reverses the order of the items within the legend. The legend displays the series names along with their corresponding symbols, allowing users to easily identify and differentiate between the various series in the chart. By default, the items in the legend are ordered by their original position (as they were added, unless the Position property of the Serie object has been used). Setting the reverse field to true reverses this order, displaying the items in the opposite sequence within the legend.
Type:
- boolean
Example
null {null}, by default, the items are ordered by their original-position (as they were added, unless the Position property of the Serie object has not been used)
true {boolean}, reverses the order of the items within the legend
reverse
(static) symbolAlign :Graph.LegendSymbolAlignmentEnum
The symbolAlign field specifies the alignment of the symbol of the serie relative to the label of the serie. The symbolWidth and symbolHeight fields can be used in conjunction with the symbolAlign field to further customize the appearance of the symbols in the legend. The symbol of the serie is the visual representation (such as a square-area) that corresponds to the serie in the chart, while the label of the serie is the text that describes the serie on the legend. By configuring the symbolAlign field, you can control how the symbol is positioned in relation to its label within the legend, allowing for a more customized and visually appealing layout. The exTop, exBottom, exLeft and exRight flags can be combined with exStart, exCenter or exEnd flags.
The shapes field defines the visual appearance of various parts of the control, as follows:
- "legendLabel", specifies the appearance of labels for series that are currently visible in the map legend
- "legendLabelHidden", specifies the appearance of labels for series that are currently hidden in the map legend
- "legendSymbol", specifies the appearance of symbols for series that are currently visible in the map legend
- "legendSymbolHidden", specifies the appearance of symbols for series that are currently hidden in the map legend
- "legendUnit", specifies the appearance of the legend unit (the client rectangle containing both the symbol and label) for visible series in the map legend
- "legendUnitHidden", specifies the appearance of the legend unit (the client rectangle containing both the symbol and label) for hidden series in the map legend
Type:
Example
null {null}, by default, the symbol is placed to the left and vertically centered relative to the label
"right" {string} or exontrol.Graph.LegendSymbolAlignmentEnum.exRight {LegendSymbolAlignmentEnum} or 4 {number}, right-aligns the symbol relative with the label
symbolAlign
(static) symbolHeight :number
The symbolHeight field indicates the height to display the symbol. The symbolAlign field specifies the alignment of the symbol of the serie relative to the label of the serie. The symbolWidth field indicates the width to display the symbol. By configuring the symbolHeight and symbolWidth fields, you can control the dimensions of the symbols displayed in the legend, allowing for a more customized and visually appealing layout. The symbol of the serie is the visual representation (such as a square-area) that corresponds to the serie in the chart, while the label of the serie is the text that describes the serie on the legend. By adjusting these fields, you can ensure that the symbols are appropriately sized and aligned in relation to their labels within the legend.
The shapes field defines the visual appearance of various parts of the control, as follows:
- "legendLabel", specifies the appearance of labels for series that are currently visible in the map legend
- "legendLabelHidden", specifies the appearance of labels for series that are currently hidden in the map legend
- "legendSymbol", specifies the appearance of symbols for series that are currently visible in the map legend
- "legendSymbolHidden", specifies the appearance of symbols for series that are currently hidden in the map legend
- "legendUnit", specifies the appearance of the legend unit (the client rectangle containing both the symbol and label) for visible series in the map legend
- "legendUnitHidden", specifies the appearance of the legend unit (the client rectangle containing both the symbol and label) for hidden series in the map legend
Type:
- number
Example
null {null}, by default, the symbolHeight is equivalent with the font's height
0 {number}, no symbol is shown
4 {number}, the symbol's height is fixed to 4-pixels tall
symbolHeight
(static) symbolWidth :number
The symbolWidth field indicates the width to display the symbol. The symbolAlign field specifies the alignment of the symbol of the serie relative to the label of the serie. The symbolHeight field indicates the height to display the symbol. By configuring the symbolWidth and symbolHeight fields, you can control the dimensions of the symbols displayed in the legend, allowing for a more customized and visually appealing layout. The symbol of the serie is the visual representation (such as a square-area) that corresponds to the serie in the chart, while the label of the serie is the text that describes the serie on the legend. By adjusting these fields, you can ensure that the symbols are appropriately sized and aligned in relation to their labels within the legend.
The shapes field defines the visual appearance of various parts of the control, as follows:
- "legendLabel", specifies the appearance of labels for series that are currently visible in the map legend
- "legendLabelHidden", specifies the appearance of labels for series that are currently hidden in the map legend
- "legendSymbol", specifies the appearance of symbols for series that are currently visible in the map legend
- "legendSymbolHidden", specifies the appearance of symbols for series that are currently hidden in the map legend
- "legendUnit", specifies the appearance of the legend unit (the client rectangle containing both the symbol and label) for visible series in the map legend
- "legendUnitHidden", specifies the appearance of the legend unit (the client rectangle containing both the symbol and label) for hidden series in the map legend
Type:
- number
Example
null {null}, by default, the symbolWidth is equivalent with the font's height
0 {number}, no symbol is shown
8 {number}, the symbol's width is fixed to 8-pixels wide
symbolWidth
(static) visible :boolean
The visible field shows or hides the legend. The legend is a panel that displays the series names along with their corresponding symbols, allowing users to easily identify and differentiate between the various series in the chart. By default, the legend is hidden (visible is null). Setting the visible field to true shows the legend, while setting it to false hides it from view.
Type:
- boolean
Example
null {null}, by default, the legend is hidden
true {boolean}, shows the legend
visible