How to display chart axis labels on ticks?
This article explains how to display chart axis labels on ticks in the React Chart.
Customize to display the axis labels on the ticks
By default, the labels are rendered between the ticks for category axis. If you want to customize and change the position of the labels to be on the ticks, you can use the labelPlacement property set to OnTicks.
In the following code example, the axis labels are displayed on the ticks.
Index.js
import { createRoot } from 'react-dom/client';
import * as React from 'react';
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ColumnSeries, Category,
Legend } from '@syncfusion/ej2-react-charts';
const Column = () => {
return (
<ChartComponent
id="charts"
primaryXAxis={{
valueType: 'Category',
interval: 1,
title: 'Months',
labelPlacement: 'OnTicks'
}}
primaryYAxis={{
minimum: 0,
maximum: 80,
interval: 10,
title: 'Temperature'
}}
title="Weather Analysis"
legendSettings={{ enableHighlight: true, position: 'Top' }}
>
<Inject services={[ColumnSeries, Category, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective
dataSource={data}
xName="x"
yName="y"
type="Column"
fill="#febe17"
name="High"
legendShape="Circle"
/>
</SeriesCollectionDirective>
</ChartComponent>
);
};
export default Column;
const root = createRoot(document.getElementById('sample'));
root.render(<Column />);
The following screenshot displays the axis labels on the ticks.
Screenshot:
Conclusion
I hope you enjoyed learning how to display chart axis labels on ticks in the React Chart Component.
You can refer to our React Chart feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for 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, support portal, or feedback portal. We are always happy to assist you!