Class PlotLabel

    • Constructor Detail

      • PlotLabel

        public PlotLabel()
    • Method Detail

      • getAlign

        public String getAlign()
        Returns horizontal alignment of the label. Can be one of "left", "center" or "right".

        Default: "center"

      • setAlign

        public void setAlign​(String align)
        Sets horizontal alignment of the label. Can be one of "left", "center" or "right".
      • getRotation

        public Number getRotation()
        Returns rotation of the text label in degrees.

        Default: 0

      • setRotation

        public void setRotation​(Number rotation)
        Sets rotation of the text label in degrees . 'rotation rotation of the text label in degrees.
      • getStyle

        public <K,​V> Map<K,​V> getStyle()
        Returns CSS styles for the text label.
        Type Parameters:
        K - type for the key

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

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

        if style was not set, type will be Object by default

        V - type for the value

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

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

        if style was not set, type will be Object by default

      • setStyle

        public void setStyle​(String style)
        Sets CSS styles for the text label.

        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 setStyle(Map)

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

        public <K,​V> void setStyle​(Map<K,​V> style)
        Sets CSS styles for the text label.

        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:
        style - the style object
      • getText

        public String getText()
        Returns the string text itself. A subset of HTML is supported.
      • setText

        public void setText​(String text)
        Sets the string text itself. A subset of HTML is supported.
      • getTextAlign

        public String getTextAlign()
        Returns the text alignment for the label. While align determines where the texts anchor point is placed within the plot band, textAlign determines how the text is aligned against its anchor point. Possible values are "left", "center" and "right". Defaults to the same as the align option.
      • setTextAlign

        public void setTextAlign​(String textAlign)
        Sets the text alignment for the label. While align determines where the texts anchor point is placed within the plot band, textAlign determines how the text is aligned against its anchor point. Possible values are "left", "center" and "right". Defaults to the same as the align option.
      • isUseHTML

        public boolean isUseHTML()
        Returns whether to use HTML to render the labels.

        Default: false

      • setUseHTML

        public void setUseHTML​(boolean useHTML)
        Sets whether to use HTML to render the labels.

        Default: false

      • getVerticalAlign

        public String getVerticalAlign()
        Returns vertical alignment of the label relative to the plot band. Can be one of "top", "middle" or "bottom".

        Default: "top"

      • setVerticalAlign

        public void setVerticalAlign​(String verticalAlign)
        Sets vertical alignment of the label relative to the plot band. Can be one of "top", "middle" or "bottom".
      • getX

        public Number getX()
        Returns horizontal position relative the alignment.

        Default varies by orientation.

      • setX

        public void setX​(Number x)
        Sets horizontal position relative the alignment. Default varies by orientation.
      • getY

        public Number getY()
        Returns vertical position of the text baseline relative to the alignment.

        Default varies by orientation.

      • setY

        public void setY​(Number y)
        Sets vertical position of the text baseline relative to the alignment. Default varies by orientation.