dataLabels

Configuration Structure

dataLabels: {
enabled: boolean,
enabledOnSeries: undefined | number[],
textAnchor: 'start' | 'middle' | 'end',
distributed: boolean,
offsetX: number | ((opts: ApexFormatterOpts) => number),
offsetY: number | ((opts: ApexFormatterOpts) => number),
style: { ... },
fontSize: string,
fontFamily: string,
fontWeight: string | number,
colors: string[],
background: { ... },
enabled: boolean,
foreColor: string,
backgroundColor: string,
borderRadius: number,
padding: number,
opacity: number,
borderWidth: number,
borderColor: string,
dropShadow: ApexDropShadow,
enabled: boolean,
top: number,
left: number,
blur: number,
opacity: number,
color: string | string[],
dropShadow: ApexDropShadow,
enabled: boolean,
top: number,
left: number,
blur: number,
opacity: number,
color: string | string[],
animate: { ... },
enabled: boolean,
countUp: { ... },
enabled: boolean,
formatter: Function,
}

enabled

Default: true

To determine whether to show dataLabels or not

enabledOnSeries

Default: undefined

Allows showing series only on specific series in a multi-series chart. For eg., if you have a line and a column chart, you can show dataLabels only on the line chart by specifying it's index in this array property.

formatter

The formatter function allows you to modify the value before displaying Example:


  formatter: function(value, { seriesIndex, dataPointIndex, w }) {
    return w.config.series[seriesIndex].name + ":  " + value
  }

In the code above, seriesIndex is useful in multi-series chart, while dataPointIndex is the index of data-point in that series. w is an object consisting all globals and configuration which can be utilized the way mentioned in the above code.

animate

Ride data labels to their new position on a data-change update instead of snapping, so the labels follow their bars through a reorder (for example a bar chart race). On by default. Bar and column charts only; speed and easing follow chart.animations.dynamicAnimation. For a worked, end-to-end example, see How to build a bar chart race.

The bars, the markers and the axis ticks all reflow on one clock, so a label that jumps to its final slot on the first frame is the odd one out: it arrives several hundred milliseconds before the bar it belongs to. A label that has not moved is a per-label no-op, so this costs nothing on an update that does not reorder.

enabled

dataLabels.animate.enabled
Default: true

Enable riding the data labels to their new slots on each update.

Available Options:

  • true (default)
  • false

countUp

Tween each numeric data label from its previous value to the new one on update, like countUp.js, instead of swapping the number instantly. Your formatter runs on every frame, so number formatting is preserved throughout the count. Off by default. Bar and column charts only.

enabled

dataLabels.countUp.enabled
Default: false

Enable the count-up value transition.

textAnchor

Default: 'middle'

The alignment of text relative to dataLabel's drawing position
Accepted values

  • start
  • middle
  • end

distributed

Default: false

Similar to plotOptions.bar.distributed, this option makes each data-label discrete. So, when you provide an array of colors in datalabels.style.colors, the index in the colors array correlates with individual data-label index of all series.

offsetX

Default: 0

Sets the left offset for dataLabels.

Accepts a number applied to every label, or a function resolved per data point. The function receives the same { series, seriesIndex, dataPointIndex, w } argument that dataLabels.style.colors accepts, and must return a number.

dataLabels: {
  offsetX: ({ seriesIndex }) => (seriesIndex === 0 ? -8 : 8),
}

dataLabels is chart-wide config, so a plain array keyed by data-point index would apply identically to every series. A function is what makes a per-series or per-point nudge possible, and it survives updateSeries where captured indices would desync. Keep it pure, as it may be called more than once per label.

offsetY

Default: 0

Sets the top offset for dataLabels.

Accepts a number applied to every label, or a function resolved per data point, with the same signature as offsetX. This is the usual way to separate labels that collide between two series at the same x:

dataLabels: {
  offsetY: ({ seriesIndex }) => (seriesIndex === 0 ? -12 : 12),
}

Supported on the line, area, bar, rangeBar, treemap and radar paths.

style

fontSize

dataLabels.style.fontSize
Default: '12px'

FontSize for the label

fontFamily

dataLabels.style.fontFamily
Default: undefined

FontFamily for the label

fontWeight

dataLabels.style.fontWeight
Default: 600

Font weight for the label. Can be String ('bold') or number (400/500)

colors

dataLabels.style.colors
Default: undefined

ForeColors for the dataLabels. Accepts an array of string colors (['#333', '#999']) or an array of functions ([function(opts) { return '#333' }]) (Each index in the array corresponds to the series).

enabled

Default: true

Should draw a background rectangle around the label

foreColor

dataLabels.background.foreColor
Default: '#fff'

Color of the label when background is enabled. This will override the colors above in style key.

borderRadius

dataLabels.background.borderRadius
Default: 2

Border radius of the background rect.

borderWidth

dataLabels.background.borderWidth
Default: 1

Border width of the background rect.

borderColor

dataLabels.background.borderColor
Default: '#fff'

Border color of the background rect.

opacity

dataLabels.background.opacity
Default: 0.9

Opacity of the background color.

dropShadow

enabled

Default: true

Enable a dropshadow for dataLabels background

top

dataLabels.background.dropShadow.top
Default: 1

Set top offset for shadow

left

dataLabels.background.dropShadow.left
Default: 1

Set left offset for shadow

blur

dataLabels.background.dropShadow.blur
Default: 1

Set blur distance for shadow

color

dataLabels.background.dropShadow.color
Default: '#000'

Set color of the shadow

opacity

dataLabels.background.opacity
Default: 0.9

Set the opacity of shadow.

dropShadow

enabled

Default: true

Enable a text dropshadow

top

dataLabels.background.dropShadow.top
Default: 1

Set top offset for text shadow

left

dataLabels.background.dropShadow.left
Default: 1

Set left offset for text shadow

blur

dataLabels.background.dropShadow.blur
Default: 1

Set blur distance for text shadow

color

dataLabels.background.dropShadow.color
Default: '#000'

Set color of the text shadow

opacity

dataLabels.background.opacity
Default: 0.9

Set the opacity of text shadow.