DevExtreme React - Customize Labels
If you need to change the text displayed by point labels, declare the customizeText function. It must return a string value. The argument of this function contains information about the point whose label is being customized. In the following example, the customizeText function instructs point labels to display both the argument and value of a point.
jQuery
$(function() { $("#pieChartContainer").dxPieChart({ // ... series: { label: { visible: true, customizeText: function (pointInfo) { return pointInfo.argument + ': ' + pointInfo.value; } } } }); });
Angular
<dx-pie-chart ... > <dxi-series> <dxo-label [visible]="true" [customizeText]="customizeText"> </dxo-label> </dxi-series> </dx-pie-chart>
import { DxPieChartModule } from "devextreme-angular"; // ... export class AppComponent { customizeText (pointInfo: any) { return pointInfo.argument + ': ' + pointInfo.value; } } @NgModule({ imports: [ // ... DxPieChartModule ], // ... })
You can also customize an individual label. For this purpose, assign a function to the customizeLabel option. This function must return an object with options for the label that you want to customize. Note that the customizeLabel option should be declared at the root level of the PieChart configuration.
jQuery
$(function() { $("#pieChartContainer").dxPieChart({ // ... series: { label: { visible: true, backgroundColor: 'blue' } }, // All point labels with the value more than 100 turn red // Other point labels remain blue customizeLabel: function (pointInfo) { return pointInfo.value > 100 ? { backgroundColor: 'red' } : { } } }); });
Angular
<dx-pie-chart [customizeLabel]="customizeLabel"> <dxi-series> <dxo-label [visible]="true" backgroundColor="blue"> </dxo-label> </dxi-series> </dx-pie-chart>
import { DxPieChartModule } from "devextreme-angular"; // ... export class AppComponent { // All point labels with the value more than 100 turn red // Other point labels remain blue customizeLabel (pointInfo: any) { return pointInfo.value > 100 ? { backgroundColor: 'red' } : { } } } @NgModule({ imports: [ // ... DxPieChartModule ], // ... })
See Also
If you have technical questions, please create a support ticket in the DevExpress Support Center.