React RangeSelector - chart.series.label

Configures point labels.

Selector: Label
Type:

Object

Declared in commonSeriesSettings, the label settings apply to all point labels in the chart. Declared in a series configuration object, the label settings apply only to the point labels that belong to this particular series. The series-specific label settings override the common ones.

App.js
  • import React from 'react';
  •  
  • import Chart, {
  • Series,
  • Label,
  • CommonSeriesSettings
  • } from 'devextreme-react/chart';
  •  
  • class App extends React.Component {
  • render() {
  • return (
  • <Chart ... >
  • <Series ... >
  • <Label ... >
  • // Settings for all point labels of an individual series
  • </Label>
  • </Series>
  • <CommonSeriesSettings ... >
  • <Label ... >
  • // Settings for all point labels in the Chart
  • </Label>
  • </CommonSeriesSettings>
  • </Chart>
  • );
  • }
  • }
  • export default App;

View Demo

See Also

alignment

Aligns point labels in relation to their points.

Default Value: 'center'

This property accepts the following values:

  • center
    Displays labels in the center of the point.

  • left
    Aligns the left corner of the label to the center of the point.

  • right
    Aligns the right corner of the label to the center of the point.

NOTE
This property has no effect if the rotated property is enabled.

argumentFormat

Formats the point argument before it is displayed in the point label. To format the point value, use the format property.

Selector: ArgumentFormat
Type:

Format

| undefined
Default Value: undefined

A point label displays only the point value by default. Using the label.customizeText property, you can instruct the label to display the point argument as well. The argumentFormat property applies in this case only. This property accepts an object whose fields are described in the format section.

See Also
  • format - provides a comprehensive overview of formatting capabilities.
  • Value Formatting - shows how to apply formatting to various UI component elements.

backgroundColor

Colors the point labels' background. The default color is inherited from the points.

Type:

String

| undefined
Default Value: undefined

This property supports the following colors:

You can remove the label's background by setting this property to "none". In this case, the label's text is the same color as the point.

View Demo

border

Configures the borders of point labels.

Selector: Border
Type:

Object

customizeText

Customizes text displayed by point labels.

Type:

Function

Function parameters:
pointInfo:

Object

Information on the series point.

Return Value:

String

Text displayed by label.

Cannot be used in themes.
NOTE
Return null to hide the series label.

This property accepts a function whose parameter exposes the following fields.

FieldDescription
originalValueThe raw value of the point.
valueThe originalValue after type cast.
valueTextThe value with an applied format and converted to string.
originalArgumentThe raw argument of the point.
argumentThe originalArgument after type cast.
argumentTextThe argument with an applied format and converted to string.
sizeThe size value of the point. For bubble series only.
index0 - if the point is minimum; 1 - if the point is maximum. For range area and range bar series only.
pointThe Point object.
seriesNameThe name of the series to which the point belongs.

The following fields are inherent to stacked-like series only.

FieldDescription
percentPoint percentage value.
percentTextThe percentage with an applied format and converted to string.
totalThe sum of all values in the stack.
totalTextThe total with an applied format and converted to string.

The following fields are inherent to financial series (candlestick and stock) only.

FieldDescription
originalOpenValueThe raw open value of the point.
openValueThe originalOpenValue after type cast.
openValueTextThe openValue with an applied format and converted to string.
originalCloseValueThe raw close value of the point.
closeValueThe originalCloseValue after type cast.
closeValueTextThe closeValue with an applied format and converted to string.
originalHighValueThe raw high value of the point.
highValueThe originalHighValue after type cast.
highValueTextThe highValue with an applied format and converted to string.
originalLowValueThe raw low value of the point.
lowValueThe originalLowValue after type cast.
lowValueTextThe lowValue with an applied format and converted to string.
reductionValueThe reduction value.
reductionValueTextThe reductionValue with an applied format and converted to string.
NOTE
As an alternative to the function’s parameter you can use the this keyword.
See Also

displayFormat

Specifies the label's text.

Type:

String

| undefined
Default Value: undefined

This property is ignored if labels are hidden.

Use the parameters of the label.customizeText function as placeholders in the displayFormat property value.

The example below illustrates how to customize label text for all series and individual series:

DevExtreme Charts - Format label text

App.js
  • import React from 'react';
  •  
  • import Chart, {
  • Series,
  • Label,
  • CommonSeriesSettings
  • } from 'devextreme-react/chart';
  •  
  • class App extends React.Component {
  • render() {
  • return (
  • <Chart ... >
  • <Series valueField="y1564" name="15-64 years"></Series>
  • <Series valueField="y014" name="0-14 years"></Series>
  • <Series valueField="y65" name="65 years and older">
  • <Label displayFormat="<u>65+ years</u>: {valueText}" >
  • </Label>
  • </Series>
  • <CommonSeriesSettings ... >
  • <Label
  • format="thousands"
  • visible={true}
  • displayFormat="{seriesName}: {valueText}"
  • >
  • </Label>
  • </CommonSeriesSettings>
  • </Chart>
  • );
  • }
  • }
  • export default App;

font

Specifies font properties for point labels.

Selector: Font
Type:

Object

format

Formats the point value before it is displayed in the point label.

Selector: Format
Type:

Format

| undefined
Default Value: undefined

See the format section for information on accepted values.

If you specify the format with an object and apply it to a full-stacked-like series, this object can also contain the percentPrecision field. Full-stacked-like series points have absolute and percentage values. The percentPrecision field specifies how many decimal digits the percentage values should have:

JavaScript
  • format: {
  • type: "fixedPoint", // the format of absolute values
  • precision: 1, // the precision of absolute values (123.456 --> 123.4)
  • percentPrecision: 2 // the precision of percentage values (12.3456 % --> 12.34 %)
  • }
See Also

horizontalOffset

Along with verticalOffset, shifts point labels from their initial positions.

Type:

Number

Default Value: 0

The number assigned to this property specifies the shift in pixels. A negative number shifts the point labels to the left, a positive number - to the right.

rotationAngle

Rotates point labels.

Type:

Number

Default Value: 0

verticalOffset

Along with horizontalOffset, shifts point labels from their initial positions.

Type:

Number

Default Value: 0

The number assigned to this property specifies the shift in pixels. A negative number shifts the point labels up, a positive number shifts them down.

visible

Makes the point labels visible.

Type:

Boolean

Default Value: false