How to add prefix and suffix for axis labels in React Chart?
This article explains how to include prefixes and suffixes for axis labels in the React Chart.
Customize the axis label prefix and suffix
You can easily customize axis labels with prefixes and suffixes using the labelFormat property.
In the following code example, the prefix and suffix are added to the primary y-axis.
Index.js
import { createRoot } from 'react-dom/client';
import * as React from 'react';
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ColumnSeries, Category
} from '@syncfusion/ej2-react-charts';
const Column = () => {
return (
<chartcomponent id="charts" primaryxaxis="{{" valuetype:="" 'category',="" interval:="" 1,="" labelplacement:="" 'onticks'="" }}="" primaryyaxis="{{" minimum:="" 0,="" maximum:="" 80,="" 10,="" labelformat:="" '${value}k'="">
<inject services="{[ColumnSeries," category]}="">
<seriescollectiondirective>
<seriesdirective datasource="{data}" xname="x" yname="y" type="Column" fill="#ffc803">
</seriesdirective></seriescollectiondirective>
</inject></chartcomponent>
);
};
export default Column;
const root = createRoot(document.getElementById('sample'));
root.render(<column>);
The following screenshot illustrate the output of the above code snippet.
Screenshot:
Refer to the working sample for additional details and implementation: View Sample in Stackblitz
Conclusion
We hope you enjoyed learning how to include prefixes and suffixes for axis labels in the React Chart Component.
You can refer to our React Chart feature tour page to learn about its other groundbreaking feature representations, and documentation to quickly get started with configuration specifications. You can also explore our React Chart example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, BoldDesk Support, or feedback portal. We are always happy to assist you!