How to remove the axis gridlines from React Chart?
This article explains how to remove the axis gridlines from the React Chart.
Customize the major grid line visibility
You can hide the visibility of major and minor grid lines by setting the width property of the majorGridLines and minorGridLines to 0 in the axis. Both primary and secondary axes support changing the visibility of major and minor grid lines.
In the following code example, the major grid lines for both axes are hidden.
Index.js
<ChartComponent
id="charts"
primaryXAxis={{
valueType: 'Double',
minimum: 0,
maximum: 1,
interval: 0.2,
majorGridLines: { width: 0 }
}}
primaryYAxis={{
minimum: 0,
maximum: 1,
interval: 0.1,
lineStyle: { width: 0 },
majorGridLines: { width: 0 }
}}
>
<Inject services={[LineSeries, Category]} />
</ChartComponent>
Screenshot:
In the following code example, only the major grid lines for the primary y-axis are hidden.
Index.js
<ChartComponent
id="charts"
primaryXAxis={{
valueType: 'Double',
minimum: 0,
maximum: 1,
interval: 0.2
}}
primaryYAxis={{
minimum: 0,
maximum: 1,
interval: 0.1,
lineStyle: { width: 0 },
majorGridLines: { width: 0 }
}}
>
<Inject services={[LineSeries, Category]} />
</ChartComponent>
Screenshot:
In the following code example, only the major grid lines for the primary x-axis are hidden.
Index.js
<ChartComponent
id="charts"
primaryXAxis={{
valueType: 'Double',
minimum: 0,
maximum: 1,
interval: 0.2,
majorGridLines: { width: 0 }
}}
primaryYAxis={{
minimum: 0,
maximum: 1,
interval: 0.1,
lineStyle: { width: 0 }
}}
>
<Inject services={[LineSeries, Category]} />
</ChartComponent>
Screenshot:
minorTicksPerInterval -This defines the number of minor grid lines to be drawn between adjacent major grid lines for each axis.
In the following code example, only the minor grid lines for the primary x-axis are hidden.
Index.js
<ChartComponent
id="charts"
primaryXAxis={{
valueType: 'Double',
minimum: 0,
maximum: 1,
interval: 0.2,
minorTicksPerInterval: 2,
minorGridLines: { width: 0 }
}}
primaryYAxis={{
minimum: 0,
maximum: 1,
interval: 0.1,
minorTicksPerInterval: 2
}}
>
<Inject services={[LineSeries, Category]} />
</ChartComponent>
Screenshot:
In the following code example, only the minor grid lines for the primary y-axis are hidden.
Index.js
<ChartComponent
id="charts"
primaryXAxis={{
valueType: 'Double',
minimum: 0,
maximum: 1,
interval: 0.2,
minorTicksPerInterval: 2
}}
primaryYAxis={{
minimum: 0,
maximum: 1,
interval: 0.1,
minorTicksPerInterval: 2,
minorGridLines: { width: 0 }
}}
>
<Inject services={[LineSeries, Category]} />
</ChartComponent>
Screenshot:
Conclusion
I hope you enjoyed learning how to remove the axis gridlines from 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!