Articles in this section
Category / Section

How to create a dotted line chart in React Chart?

4 mins read

This article explains how to create a dotted line chart in the React Chart.

Customize the creation of a dotted line chart

A line chart displays data as a series of connected data points through straight line segments. In React Chart, you can create a dotted line chart using the dashArray property. This property defines the pattern of dashes and gaps used to stroke lines in Line type series.

In the following code example, the line chart is customized to plot a dotted line using the dashArray property.

Index.js

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

const DashedLine = () => {
return (
   <ChartComponent
     id="charts"
     background="#2a3666"
   >
     <Inject services={[LineSeries, Category]} />
     <SeriesCollectionDirective>
       <SeriesDirective
         dataSource={data}
         xName="x"
         yName="y"
         width={4}
         marker={{ visible: false, width: 7, height: 7 }}
         type="Line"
         dashArray="3,2"
         fill="#719daa"
       ></SeriesDirective>
       <SeriesDirective
         dataSource={data}
         xName="x"
         yName="y1"
         width={4}
         marker={{ visible: false, width: 7, height: 7, shape: 'Diamond' }}
         dashArray="1,2"
         type="Line"
         fill="#f25959"
       ></SeriesDirective>
       <SeriesDirective
         dataSource={data}
         xName="x"
         yName="y2"
         width={4}
         marker={{ visible: false, width: 7, height: 7, shape: 'Diamond' }}
         dashArray="9,1"
         type="Line"
         fill="#d8d79b"
       ></SeriesDirective>
     </SeriesCollectionDirective>
   </ChartComponent>
);
};
export default DashedLine;

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

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

Screenshot:

React dotted line chart

View Sample in Stackblitz

Conclusion

I hope you enjoyed learning how to create a dotted line chart 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!

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