Class Legend

  • All Implemented Interfaces:
    Serializable

    public class Legend
    extends Object
    implements Serializable
    The chart legend displays data about the datasets that are appearing on the chart. The legend configuration is passed into the options.legend namespace. The global options for the chart legend is defined in Chart.defaults.global.legend.
    See Also:
    Serialized Form
    • Constructor Detail

      • Legend

        public Legend()
    • Method Detail

      • isDisplay

        public boolean isDisplay()
        Is the legend shown?
        Returns:
        the display
      • setDisplay

        public void setDisplay​(boolean display)
        Set if the legend is shown.
        Parameters:
        display - the display to set
      • getPosition

        public String getPosition()
        Position of the legend. top, left, bottom, right.
        Returns:
        the position
      • setPosition

        public void setPosition​(String position)
        Position of the legend. top, left, bottom, right.
        Parameters:
        position - the position to set
      • getAlign

        public String getAlign()
        Alignment of the legend. Options are:'start','center','end'. Defaults to 'center' for unrecognized values.
        Returns:
        the align
      • setAlign

        public void setAlign​(String align)
        Alignment of the legend. Options are:'start','center','end'. Defaults to 'center' for unrecognized values.
        Parameters:
        align - the align to set
      • isFullWidth

        public boolean isFullWidth()
        Marks that this box should take the full width of the canvas (pushing down other boxes). This is unlikely to need to be changed in day-to-day use.
        Returns:
        the fullWidth
      • setFullWidth

        public void setFullWidth​(boolean fullWidth)
        Marks that this box should take the full width of the canvas (pushing down other boxes). This is unlikely to need to be changed in day-to-day use.
        Parameters:
        fullWidth - the fullWidth to set
      • isReverse

        public boolean isReverse()
        Legend will show datasets in reverse order.
        Returns:
        the reverse
      • setReverse

        public void setReverse​(boolean reverse)
        Legend will show datasets in reverse order.
        Parameters:
        reverse - the reverse to set
      • isRtl

        public boolean isRtl()
        For rendering the legends from right to left.
        Returns:
        the rtl
      • setRtl

        public void setRtl​(boolean rtl)
        For rendering the legends from right to left.
        Parameters:
        rtl - the rtl to set
      • getTextDirection

        public String getTextDirection()
        Text Direction 'ltr' or 'rtl' regardless of the css specified on the canvas.
        Returns:
        the textDirection
      • setTextDirection

        public void setTextDirection​(String textDirection)
        Text Direction 'ltr' or 'rtl' regardless of the css specified on the canvas.
        Parameters:
        textDirection - the textDirection to set
      • getLabels

        public LegendLabel getLabels()
        The legend label configuration is nested below the legend configuration using the labels key.
        Returns:
        the labels
      • setLabels

        public void setLabels​(LegendLabel labels)
        The legend label configuration is nested below the legend configuration using the labels key.
        Parameters:
        labels - the labels to set
      • encode

        public String encode()
                      throws IOException
        Write the common options of the legend.
        Returns:
        options as JSON object
        Throws:
        IOException - If an I/O error occurs