Articles in this section

Remove comma in Indexed category axis labels in EJ2 React Chart.

This article explains how to remove comma in indexed category axis labels in React Chart.

Customize to remove comma in indexed category axis labels

To display the x-values of the first series in the axis labels, instead of showing all x-values separated by commas, you can use the axislabelrender event in the Indexed Category Axis. This event allows customization of the axis labels according to your preferences.

The code snippet below demonstrates how to remove commas from Indexed Category Axis labels using the axislabelrender event.

Index.js

import { createRoot } from 'react-dom/client';
import * as React from 'react';
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Category, ColumnSeries, DataLabel
} from '@syncfusion/ej2-react-charts';

const IndexedAxis = () => {
const axisLabelRender = (args) => {
     if (args.axis.name === 'primaryXAxis') {
           args.text = args.text.split(',')[0].trim();
     }
};
return (
   <chartcomponent id="charts" primaryxaxis="{{" valuetype:="" 'category',="" interval:="" 1,="" isindexed:="" true="" }}="" axislabelrender="{axisLabelRender.bind(this)}" primaryyaxis="{{" labelformat:="" '{value}%'="" title="Internet Users - 2016">
     <inject services="{[Category," columnseries,="" datalabel]}="">
     <seriescollectiondirective>
       <seriesdirective datasource="{data1}" xname="x" yname="y" type="Column">
       <seriesdirective datasource="{data2}" xname="x" yname="y" type="Column">
     </seriesdirective></seriesdirective></seriescollectiondirective>
   </inject></chartcomponent>
   );
};
export default IndexedAxis;

const root = createRoot(document.getElementById('sample'));
root.render(<indexedaxis>);

Comparatively, the screenshots below illustrate the outcome of the preceding code snippet.

Screenshot:

Before Solution After Solution
React chart before removing comma in indexed category axis labels
React chart after removing comma in indexed category axis labels

Refer to the working sample for additional details and implementation: View Sample in Stackblitz

Conclusion

We hope you enjoyed learning how to remove comma in indexed category axis labels in React Chart Component.

You can refer to our React Chart feature tour page to learn about its other groundbreaking feature representations and documentation, as well as how 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!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied