Articles in this section
Category / Section

How to change the legend icon shape?

5 mins read

This article explains how to change the legend icon shape in React Chart.

Customize the legend icon shape

You can change the shape of the legend icon by using the legendShape property in the series. By default, the shape of the legend icon depends on the type of the series used in the chart.

The legendShape property includes the following shapes:

• Circle
• Rectangle
• Triangle
• Diamond
• Cross
• HorizontalLine
• VerticalLine
• Pentagon
• InvertedTriangle
• SeriesType
• Image

In the code example below, the shape of the legend has been changed to a circle, a inverted triangle, and a series type.

Index.js

import { createRoot } from 'react-dom/client';
import * as React from 'react';
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, ColumnSeries, Highlight
   } from '@syncfusion/ej2-react-charts';
   
const Column = () => {
return (
   <ChartComponent
     id="charts"
     legendSettings={{ enableHighlight: true, position: 'Top' }}
   >
     <Inject services={[ColumnSeries, Legend, Category, Highlight]} />
     <SeriesCollectionDirective>
       <SeriesDirective
         dataSource={data1}
         xName="x"
         columnSpacing={0.1}
         yName="y"
         name="Gold"
         type="Column"
         legendShape="Circle"
       />
       <SeriesDirective
         dataSource={data2}
         xName="x"
         columnSpacing={0.1}
         yName="y"
         name="Silver"
         type="Column"
         legendShape="SeriesType"
       />
       <SeriesDirective
         dataSource={data3}
         xName="x"
         columnSpacing={0.1}
         yName="y"
         name="Bronze"
         type="Column"
         legendShape="InvertedTriangle"
       />
     </SeriesCollectionDirective>
   </ChartComponent>
 );
};
export default Column;

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

The screenshot below shows the outcomes of the code above.

Screenshot:

React chart legend icon shape

View Sample in Stackblitz

Conclusion

I hope you enjoyed learning how to change the legend icon shape in 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