Class Legend

    • Constructor Detail

      • Legend

        public Legend()
    • Method Detail

      • setAccessibility

        public void setAccessibility​(LegendAccessibility accessibility)
        Accessibility options for the legend, or create a new one.

        Default: an instance of LegendAccessibility

        Since:
        10.2.1.0
      • getAlign

        public String getAlign()
        Returns the horizontal alignment of the legend box within the chart area. Valid values are "left", "center" and "right".

        Default: "center".

      • setAlign

        public void setAlign​(String align)
        Sets the horizontal alignment of the legend box within the chart area. Valid values are "left", "center" and "right".
      • isAlignColumns

        public boolean isAlignColumns()
        Returns if the layout is horizontal and the legend items span over two lines or more, whether to align the items into vertical columns. Setting this to false makes room for more items, but will look more messy.

        Default: true

        Since:
        7.2.1.0
      • setAlignColumns

        public void setAlignColumns​(boolean alignColumns)
        Sets if the layout is horizontal and the legend items span over two lines or more, whether to align the items into vertical columns. Setting this to false makes room for more items, but will look more messy.
        Since:
        7.2.1.0
      • getBackgroundColor

        public Color getBackgroundColor()
        Returns the background color of the legend, filling the rounded corner border.

        Default: null.

      • setBackgroundColor

        public void setBackgroundColor​(Color color)
        Sets the background color of the legend, filling the rounded corner border.
      • setBackgroundColor

        public void setBackgroundColor​(String color)
        Sets the background color of the legend, filling the rounded corner border.
      • setBackgroundColor

        public void setBackgroundColor​(LinearGradient color)
        Sets the background color of the legend, filling the rounded corner border.
      • setBackgroundColor

        public void setBackgroundColor​(RadialGradient color)
        Sets the background color of the legend, filling the rounded corner border.
      • getBorderColor

        public Color getBorderColor()
        Returns the color of the drawn border around the legend.

        Default: "#909090".

      • setBorderColor

        public void setBorderColor​(Color color)
        Sets the color of the drawn border around the legend.
      • setBorderColor

        public void setBorderColor​(String color)
        Sets the color of the drawn border around the legend.
      • setBorderColor

        public void setBorderColor​(LinearGradient color)
        Sets the color of the drawn border around the legend.
      • setBorderColor

        public void setBorderColor​(RadialGradient color)
        Sets the color of the drawn border around the legend.
      • getBorderRadius

        public Object getBorderRadius()
        Returns the border corner radius of the legend.

        Default: 0.

        Returns:
        borderRadius the border corner radius of the legend
      • setBorderRadius

        public void setBorderRadius​(Number borderRadius)
        Sets the border corner radius of the legend.
        Parameters:
        borderRadius - the border corner radius of the legend
      • setBorderRadius

        public void setBorderRadius​(String borderRadius)
        Sets the border corner radius of the legend.
        Parameters:
        borderRadius - the border corner radius of the legend
      • getBorderWidth

        public Number getBorderWidth()
        Returns the width of the drawn border around the legend.

        Default: 0.

        Returns:
        borderWidth the width of the drawn border around the legend
      • setBorderWidth

        public void setBorderWidth​(Number borderWidth)
        Sets the width of the drawn border around the legend.
      • isEnabled

        public boolean isEnabled()
        Returns enable or disable the legend.

        Default: true.

        Returns:
        enabled enable or disable the legend
      • setEnabled

        public void setEnabled​(boolean enabled)
        Sets enable or disable the legend.
        Parameters:
        enabled - enable or disable the legend
      • getBubbleLegend

        public BubbleLegend getBubbleLegend()
        Returns the bubble legend, which is an additional element in legend which presents the scale of the bubble series. Creates a new one if none is set. Individual bubble ranges can be defined by user or calculated from series. In the case of automatically calculated ranges, a 1px margin of error is permitted.
        Since:
        7.2.1.0
      • setBubbleLegend

        public void setBubbleLegend​(BubbleLegend bubbleLegend)
        Sets the bubble legend, which is an additional element in legend which presents the scale of the bubble series. Individual bubble ranges can be defined by user or calculated from series. In the case of automatically calculated ranges, a 1px margin of error is permitted.
        Since:
        7.2.1.0
      • isFloating

        public boolean isFloating()
        Returns when the legend is floating, the plot area ignores it and is allowed to be placed below it.

        Default: false.

        Returns:
        floating when the legend is floating, the plot area ignores it and is allowed to be placed below it
      • setFloating

        public void setFloating​(boolean floating)
        Sets when the legend is floating, the plot area ignores it and is allowed to be placed below it.
        Parameters:
        floating - when the legend is floating, the plot area ignores it and is allowed to be placed below it
      • getItemDistance

        public Number getItemDistance()
        Returns in a legend with horizontal layout, the itemDistance defines the pixel distance between each item.

        Default: 8.

        Returns:
        itemDistance in a legend with horizontal layout, the itemDistance defines the pixel distance between each item
      • setItemDistance

        public void setItemDistance​(Number itemDistance)
        Sets in a legend with horizontal layout, the itemDistance defines the pixel distance between each item.
        Parameters:
        itemDistance - in a legend with horizontal layout, the itemDistance defines the pixel distance between each item
      • getItemHiddenStyle

        public <K,​V> Map<K,​V> getItemHiddenStyle()
        Returns CSS styles for each legend item when the corresponding series or point is hidden. Only a subset of CSS is supported, notably those options related to text. Properties are inherited from style unless overridden here. Defaults to:
         color: #CCC;
         
        Type Parameters:
        K - type for the key

        if style was set using setItemHiddenStyle(String), type will be String

        if style was set using setItemHiddenStyle(Map), type will be the same as the type from the key of the map

        if style was not set, default style will be applied, and type will be String

        V - type for the value

        if style was set using setItemHiddenStyle(String), type will be String

        if style was set using setItemHiddenStyle(Map), type will be the same as the type from the key of the map

        if style was not set, default style will be applied, and type will be String

      • setItemHiddenStyle

        public void setItemHiddenStyle​(String itemHiddenStyle)
        Sets CSS styles for each legend item when the corresponding series or point is hidden. Only a subset of CSS is supported, notably those options related to text. Properties are inherited from style unless overridden here.

        This method allows simple settings like

        
         label.setStyle("fontWeight: 'bold'; color: 'white'; textShadow: '0px 1px 2px black'");
         

        In the format of CSS key:value, and ";" separating multiple key:value pairs, if you have more a complex CSS styling, we recommend using setItemHiddenStyle(Map)

        Parameters:
        itemHiddenStyle - one or many CSS key:value pairs in a single line string format
      • setItemHiddenStyle

        public <K,​V> void setItemHiddenStyle​(Map<K,​V> itemHiddenStyle)
        Sets CSS styles for each legend item when the corresponding series or point is hidden. Only a subset of CSS is supported, notably those options related to text. Properties are inherited from style unless overridden here.

        This method allows complex styling like:

         
         Map<String, Object> styles = new HashMap<String, Object>();
         styles.put("fill", "#E8E8EA");
         styles.put("stroke", "#6E6E78");
         styles.put("stroke-width", "1");
         styles.put("r", "0");
         Map<String, Object> states = new HashMap<String, Object>();
         Map<String, String> hover = new HashMap<String, String>();
         hover.put("fill", "#F4F4F6");
         hover.put("stroke", "#6E6E78");
         hover.put("stroke-width", "1");
         hover.put("r", "0");
         states.put("hover", hover);
         styles.put("states", states);
         Map<String, String> style = new HashMap<String, String>();
         style.put("color", "#4D5663");
         style.put("fontSize", "12px");
         style.put("fontFamily", "'Arial'");
         style.put("fontWeight", "normal");
         style.put("padding", "10px");
         styles.put("style", style);
         
        which will generate the final results like:
        
         {
             "fill": "#E8E8EA",
             "stroke": "#6E6E78",
             "stroke-width": "1",
             "r": "0",
             "states":
             {
                 "hover":
                 {
                     "fill": "#F4F4F6",
                     "stroke": "#6E6E78",
                     "stroke-width": "1",
                     "r": "0"
                 }
             },
             "style":
             {
                 "color": "#4D5663",
                 "fontSize": "12px",
                 "fontFamily": "'Arial'",
                 "fontWeight": "normal",
                 "padding": "10px"
             }
         }
         
        Type Parameters:
        K - Type for the key, usually String
        V - Type for the value, usually String. For nested maps, use Object or any other type.
        Parameters:
        itemHiddenStyle - the style object
      • getItemHoverStyle

        public <K,​V> Map<K,​V> getItemHoverStyle()
        Returns CSS styles for each legend item in hover mode. Only a subset of CSS is supported, notably those options related to text. Properties are inherited from style unless overridden here. Defaults to:
         color: #000;
         
        Type Parameters:
        K - type for the key

        if style was set using setItemHoverStyle(String), type will be String

        if style was set using setItemHoverStyle(Map), type will be the same as the type from the key of the map

        if style was not set, default style will be applied, and type will be String

        V - type for the value

        if style was set using setItemHoverStyle(String), type will be String

        if style was set using setItemHoverStyle(Map), type will be the same as the type from the key of the map

        if style was not set, default style will be applied, and type will be String

      • setItemHoverStyle

        public void setItemHoverStyle​(String itemHoverStyle)
        Sets CSS styles for each legend item in hover mode. Only a subset of CSS is supported, notably those options related to text. Properties are inherited from style unless overridden here.

        This method allows simple settings like

        
         label.setStyle("fontWeight: 'bold'; color: 'white'; textShadow: '0px 1px 2px black'");
         

        In the format of CSS key:value, and ";" separating multiple key:value pairs, if you have more a complex CSS styling, we recommend using setItemHoverStyle(Map)

        Parameters:
        itemHoverStyle - one or many CSS key:value pairs in a single line string format
      • setItemHoverStyle

        public <K,​V> void setItemHoverStyle​(Map<K,​V> itemHoverStyle)
        Sets CSS styles for each legend item in hover mode. Only a subset of CSS is supported, notably those options related to text. Properties are inherited from style unless overridden here.

        This method allows complex styling like:

         
         Map<String, Object> styles = new HashMap<String, Object>();
         styles.put("fill", "#E8E8EA");
         styles.put("stroke", "#6E6E78");
         styles.put("stroke-width", "1");
         styles.put("r", "0");
         Map<String, Object> states = new HashMap<String, Object>();
         Map<String, String> hover = new HashMap<String, String>();
         hover.put("fill", "#F4F4F6");
         hover.put("stroke", "#6E6E78");
         hover.put("stroke-width", "1");
         hover.put("r", "0");
         states.put("hover", hover);
         styles.put("states", states);
         Map<String, String> style = new HashMap<String, String>();
         style.put("color", "#4D5663");
         style.put("fontSize", "12px");
         style.put("fontFamily", "'Arial'");
         style.put("fontWeight", "normal");
         style.put("padding", "10px");
         styles.put("style", style);
         
        which will generate the final results like:
        
         {
             "fill": "#E8E8EA",
             "stroke": "#6E6E78",
             "stroke-width": "1",
             "r": "0",
             "states":
             {
                 "hover":
                 {
                     "fill": "#F4F4F6",
                     "stroke": "#6E6E78",
                     "stroke-width": "1",
                     "r": "0"
                 }
             },
             "style":
             {
                 "color": "#4D5663",
                 "fontSize": "12px",
                 "fontFamily": "'Arial'",
                 "fontWeight": "normal",
                 "padding": "10px"
             }
         }
         
        Type Parameters:
        K - Type for the key, usually String
        V - Type for the value, usually String. For nested maps, use Object or any other type.
        Parameters:
        itemHoverStyle - the style object
      • getItemMarginBottom

        public Number getItemMarginBottom()
        Returns the pixel bottom margin for each legend item.

        Default: 0

      • setItemMarginBottom

        public void setItemMarginBottom​(Number itemMarginBottom)
        Sets the pixel bottom margin for each legend item.
      • getItemMarginTop

        public Number getItemMarginTop()
        Returns the pixel top margin for each legend item.

        Default: 0

      • setItemMarginTop

        public void setItemMarginTop​(Number itemMarginTop)
        Sets the pixel top margin for each legend item.
      • getItemStyle

        public <K,​V> Map<K,​V> getItemStyle()
        Returns CSS styles for each legend item. Only a subset of CSS is supported, notably those options related to text. Defaults to:
         cursor: pointer; color: #274b6d; fontSize: 12px;
         
        Type Parameters:
        K - type for the key

        if style was set using setItemStyle(String), type will be String

        if style was set using setItemStyle(Map), type will be the same as the type from the key of the map

        if style was not set, default style will be applied, and type will be String

        V - type for the value

        if style was set using setItemStyle(String), type will be String

        if style was set using setItemStyle(Map), type will be the same as the type from the key of the map

        if style was not set, default style will be applied, and type will be String

      • setItemStyle

        public void setItemStyle​(String itemStyle)
        Sets CSS styles for each legend item. Only a subset of CSS is supported, notably those options related to text.

        This method allows simple settings like

        
         label.setStyle("fontWeight: 'bold'; color: 'white'; textShadow: '0px 1px 2px black'");
         

        In the format of CSS key:value, and ";" separating multiple key:value pairs, if you have more a complex CSS styling, we recommend using setItemStyle(Map)

        Parameters:
        itemStyle - one or many CSS key:value pairs in a single line string format
      • setItemStyle

        public <K,​V> void setItemStyle​(Map<K,​V> itemStyle)
        Sets CSS styles for each legend item. Only a subset of CSS is supported, notably those options related to text.

        This method allows complex styling like:

         
         Map<String, Object> styles = new HashMap<String, Object>();
         styles.put("fill", "#E8E8EA");
         styles.put("stroke", "#6E6E78");
         styles.put("stroke-width", "1");
         styles.put("r", "0");
         Map<String, Object> states = new HashMap<String, Object>();
         Map<String, String> hover = new HashMap<String, String>();
         hover.put("fill", "#F4F4F6");
         hover.put("stroke", "#6E6E78");
         hover.put("stroke-width", "1");
         hover.put("r", "0");
         states.put("hover", hover);
         styles.put("states", states);
         Map<String, String> style = new HashMap<String, String>();
         style.put("color", "#4D5663");
         style.put("fontSize", "12px");
         style.put("fontFamily", "'Arial'");
         style.put("fontWeight", "normal");
         style.put("padding", "10px");
         styles.put("style", style);
         
        which will generate the final results like:
        
         {
             "fill": "#E8E8EA",
             "stroke": "#6E6E78",
             "stroke-width": "1",
             "r": "0",
             "states":
             {
                 "hover":
                 {
                     "fill": "#F4F4F6",
                     "stroke": "#6E6E78",
                     "stroke-width": "1",
                     "r": "0"
                 }
             },
             "style":
             {
                 "color": "#4D5663",
                 "fontSize": "12px",
                 "fontFamily": "'Arial'",
                 "fontWeight": "normal",
                 "padding": "10px"
             }
         }
         
        Type Parameters:
        K - Type for the key, usually String
        V - Type for the value, usually String. For nested maps, use Object or any other type.
        Parameters:
        itemStyle - the style object
      • getItemWidth

        public Number getItemWidth()
        Returns the width for each legend item. This is useful in a horizontal layout with many items when you want the items to align vertically. .

        Default: null.

      • setItemWidth

        public void setItemWidth​(Number itemWidth)
        Sets the width for each legend item. This is useful in a horizontal layout with many items when you want the items to align vertically. .
        Parameters:
        itemWidth - the width for each legend item
      • getLabelFormat

        public String getLabelFormat()
        Returns a format string for each legend label. Available variables relates to properties on the series, or the point in case of pies.

        Default: "{name}".

      • setLabelFormat

        public void setLabelFormat​(String labelFormat)
        Sets a format string for each legend label. Available variables relates to properties on the series, or the point in case of pies.
      • getLayout

        public String getLayout()
        Returns the layout of the legend items. Can be one of "horizontal" or "vertical" or "proximate".

        Default: "horizontal".

      • setLayout

        public void setLayout​(String layout)
        Sets the layout of the legend items. Can be one of "horizontal" or "vertical" or "proximate".
        Parameters:
        layout - the layout of the legend items
      • getMargin

        public Number getMargin()
        Returns if 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.

        Default: 15.

      • setMargin

        public void setMargin​(Number margin)
        Sets if 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.
      • getMaxHeight

        public Number getMaxHeight()
        Returns maximum pixel height for the legend. When the maximum height is extended, navigation will show.
        Returns:
        maxHeight maximum pixel height for the legend
      • setMaxHeight

        public void setMaxHeight​(Number maxHeight)
        Sets maximum pixel height for the legend. When the maximum height is extended, navigation will show.
        Parameters:
        maxHeight - maximum pixel height for the legend
      • getPadding

        public Number getPadding()
        Returns the inner padding of the legend box.

        Default: 8.

        Returns:
        padding the inner padding of the legend box
      • setPadding

        public void setPadding​(Number padding)
        Sets the inner padding of the legend box.
        Parameters:
        padding - the inner padding of the legend box
      • isReversed

        public boolean isReversed()
        Returns whether to reverse the order of the legend items compared to the order of the series or points as defined in the configuration object.

        Default: false.

      • setReversed

        public void setReversed​(boolean reversed)
        Sets whether to reverse the order of the legend items compared to the order of the series or points as defined in the configuration object.
      • isRtl

        public boolean isRtl()
        Returns whether to show the symbol on the right side of the text rather than the left side. This is common in Arabic and Hebraic.

        Default: false.

      • setRtl

        public void setRtl​(boolean rtl)
        Sets whether to show the symbol on the right side of the text rather than the left side. This is common in Arabic and Hebraic.
      • isShadow

        public boolean isShadow()
        Returns whether to apply a drop shadow to the legend. Requires that backgroundColor be set.

        Default: false.

        See Also:
        Shadow
      • getShadow

        public Shadow getShadow()
        Returns whether to apply a drop shadow to the legend. Requires that backgroundColor be set.

        Default: Shadow.NONE.

        See Also:
        Shadow
      • setShadow

        public void setShadow​(boolean shadow)
        Sets whether to apply a drop shadow to the legend. Requires that backgroundColor be set.
      • setShadow

        public void setShadow​(Shadow shadow)
        Sets whether to apply a drop shadow to the legend. Requires that backgroundColor be set.
        See Also:
        Shadow
      • isSquareSymbol

        public boolean isSquareSymbol()
        When this is true, the legend symbol width will be the same as the symbol height, which in turn defaults to the font size of the legend items.

        Default: true

        Since:
        7.2.1.0
      • setSquareSymbol

        public void setSquareSymbol​(boolean squareSymbol)
        When this is true, the legend symbol width will be the same as the symbol height, which in turn defaults to the font size of the legend items.
        Since:
        7.2.1.0
      • getSymbolHeight

        public Number getSymbolHeight()
        Returns the pixel height of the legend item symbol.

        Default: 12.

      • setSymbolHeight

        public void setSymbolHeight​(Number symbolHeight)
        Sets the pixel height of the legend item symbol.
      • getSymbolPadding

        public Number getSymbolPadding()
        Returns the pixel padding between the legend item symbol and the legend item text.

        Default: 5.

      • setSymbolPadding

        public void setSymbolPadding​(Number symbolPadding)
        Sets the pixel padding between the legend item symbol and the legend item text.
      • getSymbolRadius

        public Number getSymbolRadius()
        Returns the pixel radius of the legend item symbol.

        Default: 2.

      • setSymbolRadius

        public void setSymbolRadius​(Number symbolRadius)
        Sets the pixel radius of the legend item symbol.
      • getSymbolWidth

        public Number getSymbolWidth()
        Returns the pixel width of the legend item symbol.

        Default: 16.

        Returns:
        symbolWidth the pixel width of the legend item symbol
      • setSymbolWidth

        public void setSymbolWidth​(Number symbolWidth)
        Sets the pixel width of the legend item symbol.
      • getTitle

        public LegendTitle getTitle()
        Returns a title to be added on top of the legend.

        Default: .

        Returns:
        title a title to be added on top of the legend
      • setTitle

        public void setTitle​(LegendTitle title)
        Sets a title to be added on top of the legend.
        Parameters:
        title - a title to be added on top of the legend
      • getVerticalAlign

        public String getVerticalAlign()
        Returns 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.

        Default: "bottom".

      • setVerticalAlign

        public void setVerticalAlign​(String verticalAlign)
        Sets 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.
      • getWidth

        public Number getWidth()
        Returns the width of the legend box.

        Default: null.

        Returns:
        the width of the legend box
      • setWidth

        public void setWidth​(Number width)
        Sets the width of the legend box.
      • getX

        public Number getX()
        Returns 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.

        Default: 0.

      • setX

        public void setX​(Number x)
        Sets 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.
      • getY

        public Number getY()
        Returns 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.

        Default: 0.

      • setY

        public void setY​(Number y)
        Sets 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.