public class DataLabels extends BaseOption
Options for the series data labels, appearing next to each data point.
Since v6.2.0, multiple data labels can be applied to each single point by defining them as an array of configs.
In styled mode, the data labels can be styled with the .highcharts-data-label-box
and .highcharts-data-label
class names (see example).
Modifier and Type | Field and Description |
---|---|
static DataLabels |
NULL |
Constructor and Description |
---|
DataLabels() |
Modifier and Type | Method and Description |
---|---|
Number |
getDistanceAsNumber()
The distance of the data label from the pie's edge.
|
String |
getDistanceAsString()
The distance of the data label from the pie's edge.
|
Boolean |
getEnabled()
Enable or disable the data labels.
|
Filter |
getFilter()
A declarative filter to control of which data labels to display.
|
String |
getFormat()
A format string for the data label.
|
CSSObject |
getStyle()
Styles for the label.
|
DataLabels |
setDistance(Number distanceAsNumber)
The distance of the data label from the pie's edge.
|
DataLabels |
setDistance(String distanceAsString)
The distance of the data label from the pie's edge.
|
DataLabels |
setEnabled(Boolean enabled)
Enable or disable the data labels.
|
DataLabels |
setFilter(Filter filter)
A declarative filter to control of which data labels to display.
|
DataLabels |
setFormat(String format)
A format string for the data label.
|
DataLabels |
setStyle(CSSObject style)
Styles for the label.
|
set_hcNulledOption
public static final DataLabels NULL
public Number getDistanceAsNumber()
The distance of the data label from the pie's edge. Negative numbers put the data label on top of the pie slices. Can also be defined as a percentage of pie's radius. Connectors are only shown for data labels outside the pie.
public DataLabels setDistance(Number distanceAsNumber)
The distance of the data label from the pie's edge. Negative numbers put the data label on top of the pie slices. Can also be defined as a percentage of pie's radius. Connectors are only shown for data labels outside the pie.
distanceAsNumber
- the value for the distanceAsNumber optionpublic String getDistanceAsString()
The distance of the data label from the pie's edge. Negative numbers put the data label on top of the pie slices. Can also be defined as a percentage of pie's radius. Connectors are only shown for data labels outside the pie.
public DataLabels setDistance(String distanceAsString)
The distance of the data label from the pie's edge. Negative numbers put the data label on top of the pie slices. Can also be defined as a percentage of pie's radius. Connectors are only shown for data labels outside the pie.
distanceAsString
- the value for the distanceAsString optionpublic Boolean getEnabled()
Enable or disable the data labels.
public DataLabels setEnabled(Boolean enabled)
Enable or disable the data labels.
enabled
- the value for the enabled optionpublic Filter getFilter()
A declarative filter to control of which data labels to display. 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.
public DataLabels setFilter(Filter filter)
A declarative filter to control of which data labels to display. 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.
filter
- the value for the filter optionpublic String getFormat()
A format string for the data label. Available variables are the same as for formatter
.
public DataLabels setFormat(String format)
A format string for the data label. Available variables are the same as for formatter
.
format
- the value for the format optionpublic CSSObject getStyle()
Styles for the label. The default color
setting is "contrast"
, which is a pseudo color that Highcharts picks up and applies the maximum contrast to the underlying point item, for example the bar in a bar chart.
The textOutline
is a pseudo property that applies an outline of the given width with the given color, which by default is the maximum contrast to the text. So a bright text color will result in a black text outline for maximum readability on a mixed background. In some cases, especially with grayscale text, the text outline doesn't work well, in which cases it can be disabled by setting it to "none"
. When useHTML
is true, the textOutline
will not be picked up. In this, case, the same effect can be acheived through the text-shadow
CSS property.
For some series types, where each point has an extent, like for example tree maps, the data label may overflow the point. There are two strategies for handling overflow. By default, the text will wrap to multiple lines. The other strategy is to set style.textOverflow
to ellipsis
, which will keep the text on one line plus it will break inside long words.
public DataLabels setStyle(CSSObject style)
Styles for the label. The default color
setting is "contrast"
, which is a pseudo color that Highcharts picks up and applies the maximum contrast to the underlying point item, for example the bar in a bar chart.
The textOutline
is a pseudo property that applies an outline of the given width with the given color, which by default is the maximum contrast to the text. So a bright text color will result in a black text outline for maximum readability on a mixed background. In some cases, especially with grayscale text, the text outline doesn't work well, in which cases it can be disabled by setting it to "none"
. When useHTML
is true, the textOutline
will not be picked up. In this, case, the same effect can be acheived through the text-shadow
CSS property.
For some series types, where each point has an extent, like for example tree maps, the data label may overflow the point. There are two strategies for handling overflow. By default, the text will wrap to multiple lines. The other strategy is to set style.textOverflow
to ellipsis
, which will keep the text on one line plus it will break inside long words.
style
- the value for the style optionCopyright © 2024. All rights reserved.