Articles in this section
Category / Section

How to customize the range of axis in React Chart?

3 mins read

This article explains how to customize the range of axis in React Chart.

Customize the range of axis

You can customize the range of the axis by using the minimum and maximum properties in the axis. By default, the axis range is calculated automatically based on the data source of the chart.

In the following code example, the minimum and maximum value is set for the primary x axis.

Index.js

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

const StepLine = () => {
return (
  <chartcomponent id="charts" primaryxaxis="{{" minimum:="" new="" date(1971,="" 6,="" 11),="" maximum:="" date(2011,="" valuetype:="" 'datetime'="" }}="" primaryyaxis="{{" interval:="" 10,="" title:="" 'production="" (in="" percentage)',="" labelformat:="" '{value}%'="" title="Fruit Production Statistics">
    <inject services="{[StepLineSeries," datetime]}="">
    <seriescollectiondirective>
      <seriesdirective datasource="{data1}" xname="x" yname="y" width="{5}" type="StepLine">
    </seriesdirective></seriescollectiondirective>
  </inject></chartcomponent>
);
};
export default StepLine;

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

The following screenshot illustrate the output of the above code snippet.

Screenshot:

React chart axis range

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

Conclusion

We hope you enjoyed learning how to customize the range of axes 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, 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, 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)
Please  to leave a comment
Access denied
Access denied