Class DataLabels

    • Constructor Detail

      • DataLabels

        public DataLabels()
    • Method Detail

      • getAlign

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

        Defaults to "center".

      • setAlign

        public void setAlign​(String align)
        Sets the alignment of the data label compared to the point. Can be one of "left", "center" or "right". Defaults to "center". 'align the alignment of the data label compared to the point. Can be one of "left", "center" or "right".

        Defaults to "center".

      • getAllowOverlap

        public boolean getAllowOverlap()
        Whether to allow data labels to overlap. To make the labels less sensitive for overlapping, the dataLabels.padding can be set to 0.

        Defaults to false.

      • setAllowOverlap

        public void setAllowOverlap​(Boolean allowOverlap)
        Whether to allow data labels to overlap. To make the labels less sensitive for overlapping, the dataLabels.padding can be set to 0.

        Defaults to false.

      • isAlternate

        public boolean isAlternate()
        Returns whether to position data labels alternately. For example, if distance is set equal to 100, then data labels will be positioned alternately (on both sides of the point) at a distance of 100px.

        Default: true

        Since:
        7.2.1.0
      • setAlternate

        public void setAlternate​(boolean alternate)
        Sets whether to position data labels alternately. For example, if distance is set equal to 100, then data labels will be positioned alternately (on both sides of the point) at a distance of 100px.
        Since:
        7.2.1.0
      • getBackgroundColor

        public Color getBackgroundColor()
        Returns the background color for the data label.

        Defaults to null.

      • setBackgroundColor

        public void setBackgroundColor​(Color color)
        Sets the background color for the data label.

        Defaults to null.

      • setBackgroundColor

        public void setBackgroundColor​(String color)
        Sets the background color for the data label.

        Defaults to null.

      • setBackgroundColor

        public void setBackgroundColor​(LinearGradient color)
        Sets the background color for the data label.

        Defaults to null.

      • setBackgroundColor

        public void setBackgroundColor​(RadialGradient color)
        Sets the background color for the data label.

        Defaults to null.

      • getBorderColor

        public Color getBorderColor()
        Returns the border color for the data label.

        Default: null

      • setBorderColor

        public void setBorderColor​(Color color)
        Sets the border color for the data label.

        Default: null

      • setBorderColor

        public void setBorderColor​(String color)
        Sets the border color for the data label.

        Default: null

      • setBorderColor

        public void setBorderColor​(LinearGradient color)
        Sets the border color for the data label.

        Default: null

      • setBorderColor

        public void setBorderColor​(RadialGradient color)
        Sets the border color for the data label.

        Default: null

      • getBorderRadius

        public Object getBorderRadius()
        Returns the border radius in pixels for the data label.

        Default: 0

      • setBorderRadius

        public void setBorderRadius​(Number borderRadius)
        Sets the border radius in pixels for the data label.
      • setBorderRadius

        public void setBorderRadius​(String borderRadius)
        Sets the border radius in pixels for the data label.
      • getBorderWidth

        public Number getBorderWidth()
        Returns the border width in pixels for the data label.

        Default: 0

      • setBorderWidth

        public void setBorderWidth​(Number borderWidth)
        Sets the border width in pixels for the data label.

        Default: 0

      • getColor

        public Color getColor()
        Returns the text color for the data labels.

        Default: null

      • setColor

        public void setColor​(Color color)
        Sets the text color for the data labels.
      • setColor

        public void setColor​(String color)
        Sets the text color for the data labels.
      • setColor

        public void setColor​(LinearGradient color)
        Sets the text color for the data labels.
      • setColor

        public void setColor​(RadialGradient color)
        Sets the text color for the data labels.
      • getConnectorColor

        public String getConnectorColor()
        Returns the color of the line connecting the data label to the pie slice. The default color is the same as the point's color.

        Default: null

      • setConnectorColor

        public void setConnectorColor​(String connectorColor)
        Sets the color of the line connecting the data label to the pie slice. The default color is the same as the point's color.
      • getConnectorShape

        public String getConnectorShape()
        Returns specifies the method that is used to generate the connector path.

        Highcharts provides 3 built-in connector shapes: 'crookedLine' (default since v11), 'fixedOffset' and 'straight'.

        Default: "crookedLine"

        Since:
        11.2.0.0
      • setConnectorShape

        public void setConnectorShape​(String connectorShape)
        Sets specifies the method that is used to generate the connector path.

        Highcharts provides 3 built-in connector shapes: 'crookedLine' (default since v11), 'fixedOffset' and 'straight'.

        Since:
        11.2.0.0
      • getConnectorWidth

        public Number getConnectorWidth()
        Returns the width of the line connecting the data label to the point.

        Default: 1

        Since:
        7.2.1.0
      • setConnectorWidth

        public void setConnectorWidth​(Number connectorWidth)
        Sets the width of the line connecting the data label to the point.
        Since:
        7.2.1.0
      • isCrop

        public boolean isCrop()
        Returns whether to hide data labels that are outside the plot area. By default, the data label is moved inside the plot area according to the setOverflow(String) option.

        Default: true

      • setCrop

        public void setCrop​(boolean crop)
        Sets whether to hide data labels that are outside the plot area. By default, the data label is moved inside the plot area according to the setOverflow(String) option.

        Default: true

      • getDefer

        public boolean getDefer()
        Return whether to defer displaying the data labels until the initial series animation has finished.

        Defaults to true.

      • setDefer

        public void setDefer​(Boolean defer)
        Set whether to defer displaying the data labels until the initial series animation has finished.

        Defaults to true.

      • getDistance

        public Object getDistance()
        Returns the distance of the data labels which is used for Pie chart only.

        Default: 0

      • setDistance

        public void setDistance​(Number distance)
        Sets the distance of the data labels which is used for Pie chart only.
      • setDistance

        public void setDistance​(String distance)
        Sets the distance of the data labels which is used for Pie chart only.
        Since:
        7.2.1.0
      • isEnabled

        public boolean isEnabled()
        Returns enable or disable the data labels.

        Default: false

      • setEnabled

        public void setEnabled​(boolean enabled)
        Sets enable or disable the data labels.

        Default: false

      • getFilter

        public DataLabelsFilter getFilter()
        Returns a declarative filter to control of which data labels to display, if any. Otherwise, create a new one. The declarative filter is designed for use when callback functions are not available, like when the chart options require a pure JSON structure or for use with graphical editors. For programmatic control, use the formatter instead, and return undefined to disable a single data label.
        Since:
        7.2.1.0
      • setFilter

        public void setFilter​(DataLabelsFilter filter)
        Sets a declarative filter to control of which data labels to display.
        Since:
        7.2.1.0
      • setFormat

        public void setFormat​(String format)
        Sets a format string for the data label.
      • getFormatter

        public org.zkoss.json.JavaScriptValue getFormatter()
        Returns a callback JavaScript function to format the data label. Note that if a format is defined, the format takes precedence and the formatter is ignored.

        Default: null

        Since:
        7.2.1.0
      • setFormatter

        public void setFormatter​(org.zkoss.json.JavaScriptValue formatter)
        Sets a callback JavaScript function to format the data label. Note that if a format is defined, the format takes precedence and the formatter is ignored.
        Since:
        7.2.1.0
      • isInside

        public boolean isInside()
        Returns for points with an extent, like columns, whether to align the data label inside the box or to the actual value point.

        Defaults to false in most cases, true in stacked columns.

      • setInside

        public void setInside​(boolean inside)
        Sets for points with an extent, like columns, whether to align the data label inside the box or to the actual value point. Defaults to false in most cases, true in stacked columns. 'inside for points with an extent, like columns, whether to align the data label inside the box or to the actual value point.

        Defaults to false in most cases, true in stacked columns.

      • getLinkFormat

        public String getLinkFormat()
        Returns the format string specifying what to show for links in the networkgraph.

        Default: null

        Since:
        7.2.1.0
      • setLinkFormat

        public void setLinkFormat​(String linkFormat)
        Sets the format string specifying what to show for links in the networkgraph.
        Since:
        7.2.1.0
      • getLinkTextPath

        public DataLabelsTextPath getLinkTextPath()
        Returns the options for a link label text which should follow link connection, if any. Otherwise, create a new one. Note: Only SVG-based renderer supports this option.
        Since:
        7.2.1.0
      • setLinkTextPath

        public void setLinkTextPath​(DataLabelsTextPath linkTextPath)
        Sets the options for a link label text which should follow link connection. Note: Only SVG-based renderer supports this option.
        Since:
        7.2.1.0
      • getNodeFormat

        public String getNodeFormat()
        Returns the format string specifying what to show for nodes. By default the nodeFormatter returns {point.name}.

        Default: null

        Since:
        10.2.1.0
      • setNodeFormat

        public void setNodeFormat​(String nodeFormat)
        Sets the format string specifying what to show for nodes. By default the nodeFormatter returns {point.name}.

        Default: null

        Since:
        10.2.1.0
      • getNodeFormatter

        public org.zkoss.json.JavaScriptValue getNodeFormatter()
        Returns the callback to format data labels for nodes in the sankey diagram. The nodeFormat option takes precedence over the nodeFormatter.

        Default: null

        Since:
        10.2.1.0
      • setNodeFormatter

        public void setNodeFormatter​(org.zkoss.json.JavaScriptValue nodeFormatter)
        Sets the callback to format data labels for nodes in the sankey diagram. The nodeFormat option takes precedence over the nodeFormatter.

        Default: null

        Since:
        10.2.1.0
      • getNullFormat

        public String getNullFormat()
        Returns the format for points with the value of null. Works analogously to format. nullFormat can be applied only to series which support displaying null points.

        Default: null

        Since:
        10.2.1.0
      • setNullFormat

        public void setNullFormat​(String nullFormat)
        Sets the format for points with the value of null. Works analogously to format. nullFormat can be applied only to series which support displaying null points.

        Default: null

        Since:
        10.2.1.0
      • getNullFormatter

        public org.zkoss.json.JavaScriptValue getNullFormatter()
        Returns the callback JavaScript function that defines formatting for points with the value of null. Works analogously to formatter. nullPointFormatter can be applied only to series which support displaying null points.

        Default: null

        Since:
        10.2.1.0
      • setNullFormatter

        public void setNullFormatter​(org.zkoss.json.JavaScriptValue nullFormatter)
        Sets the callback JavaScript function that defines formatting for points with the value of null. Works analogously to formatter. nullPointFormatter can be applied only to series which support displaying null points.

        Default: null

        Since:
        10.2.1.0
      • getOverflow

        public String getOverflow()
        Returns how to handle data labels that flow outside the plot area.

        The default is justify, which aligns them inside the plot area. For columns and bars, this means it will be moved inside the bar. To display data labels outside the plot area, set crop to false and overflow to "none".

      • setOverflow

        public void setOverflow​(String overflow)
        Returns how to handle data labels that flow outside the plot area.

        The default is justify, which aligns them inside the plot area. For columns and bars, this means it will be moved inside the bar. To display data labels outside the plot area, set setCrop(boolean) to false and setOverflow(String) to "none".

      • getPointFormat

        public String getPointFormat()
        Returns the point format of DataLabels.

        Default: null

        Since:
        11.2.0.0
      • setPointFormat

        public void setPointFormat​(String pointFormat)
        Sets the point format of DataLabels.
        Since:
        11.2.0.0
      • getRotation

        public Object getRotation()
        Returns text rotation in degrees. Note that due to a more complex structure, backgrounds and borders will be lost on a rotated data label.

        Default: 0

      • setRotation

        public void setRotation​(Number rotation)
        Sets text rotation in degrees. Note that due to a more complex structure, backgrounds and borders will be lost on a rotated data label.
      • setRotation

        public void setRotation​(String rotation)
        Sets text rotation in degrees. Note that due to a more complex structure, backgrounds and borders will be lost on a rotated data label.
      • getRotationMode

        public String getRotationMode()
        Returns a rotationMode on all points which lies on the same level.

        Default: null

        Since:
        7.2.1.0
      • setRotationMode

        public void setRotationMode​(String rotationMode)
        Sets a rotationMode on all points which lies on the same level.
        Since:
        7.2.1.0
      • isShadow

        public boolean isShadow()
        Returns whether to apply a drop shadow to the data label area. Works best with borderWidth or backgroundColor.

        Default: false.

        See Also:
        Shadow
      • getShadow

        public Shadow getShadow()
        Returns whether to apply a drop shadow to the outer chart area. Works best with borderWidth or backgroundColor.

        Default: Shadow.NONE.

        See Also:
        Shadow
      • setShadow

        public void setShadow​(boolean shadow)
        Sets whether to apply a drop shadow to the outer chart area. Works best with borderWidth or backgroundColor.
      • setShadow

        public void setShadow​(Shadow shadow)
        Sets whether to apply a drop shadow to the outer chart area. Works best with borderWidth or backgroundColor.
        See Also:
        Shadow
      • getShape

        public String getShape()
        Return the name of a symbol to use for the border around the label. Symbols are predefined functions on the Renderer object.

        Defaults to square.

      • setShape

        public void setShape​(String shape)
        Set the name of a symbol to use for the border around the label. Symbols are predefined functions on the Renderer object.

        Defaults to square.

      • isSoftConnector

        public boolean isSoftConnector()
        Returns whether to enable soft connector. Funnel chart only.
      • setSoftConnector

        public void setSoftConnector​(boolean softConnector)
        Sets to enable soft connector. Funnel chart only.
      • getStyle

        public <K,​V> Map<K,​V> getStyle()
        Returns styles for the label. Defaults to:
         color: 'contrast'; fontSize: '11px'; fontWeight: 'bold'; textShadow: '0 0 6px contrast, 0 0 3px contrast'
         
        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, default style will be applied, and type will be String

        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, default style will be applied, and type will be String

      • setStyle

        public void setStyle​(String style)
        Set styles for the 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)
        Set styles for the 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
      • getTextPath

        public DataLabelsTextPath getTextPath()
        Returns options for a label text which should follow marker's shape, if any. Otherwise, create a new one. Border and background are disabled for a label that follows a path. Note: Only SVG-based renderer supports this option. Setting useHTML to true will disable this option.
        Since:
        7.2.1.0
      • setTextPath

        public void setTextPath​(DataLabelsTextPath textPath)
        Sets options for a label text which should follow marker's shape. Border and background are disabled for a label that follows a path. Note: Only SVG-based renderer supports this option. Setting useHTML to true will disable this option.
        Since:
        7.2.1.0
      • isUseHTML

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

        Defaults to false.

      • setUseHTML

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

        Defaults to false.

      • getVerticalAlign

        public String getVerticalAlign()
        Returns the vertical alignment of a data label. Can be one of top, middle or bottom.

        The default value depends on the data, for instance in a column chart, the label is above positive values and below negative values.

      • setVerticalAlign

        public void setVerticalAlign​(String verticalAlign)
        Sets the vertical alignment of a data label. Can be one of top, middle, center or bottom.

        The default value depends on the data, for instance in a column chart, the label is above positive values and below negative values.

      • getX

        public Number getX()
        Returns the x position offset of the label relative to the point.

        Default: 0

      • setX

        public void setX​(Number x)
        Sets the x position offset of the label relative to the point.

        Default: 0

      • getY

        public Number getY()
        Returns the y position offset of the label relative to the point.

        Default: -6

      • setY

        public void setY​(Number y)
        Sets the y position offset of the label relative to the point.

        Default: -6

      • getZIndex

        public Number getZIndex()
        Returns the Z index of the data labels.

        The default Z index puts it above the series. Use a Z index of 2 to display it behind the series.

        Default: 6

      • setZIndex

        public void setZIndex​(Number zIndex)
        Sets the Z index of the data labels.

        The default Z index puts it above the series. Use a Z index of 2 to display it behind the series.

        Default: 6