Articles in this section
Category / Section

How to select the entire stacking series point in React Chart?

3 mins read

This article explains how to select the entire stacking series point in the React Chart.

Customize the entire selection

You can select the point in a stacking series that corresponds to the same index in all the series by setting the selectionMode to Cluster. You can customize the style of the selection by using selectionStyle property in chart series.

In the following code example, the entire stacking series is selected and customized with CSS styles.

Index.js

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

const SelectionChart = () => {
 const primaryxAxis = { valueType: 'Category' };
 const primaryyAxis = { minimum: 0, maximum: 40, interval: 5 };
 return (
   <ChartComponent
     id="charts"
     primaryXAxis={primaryxAxis}
     primaryYAxis={primaryyAxis}
     selectionMode="Cluster"
     width="75%"
     height="75%"
   >
     <Inject services={[StackingColumnSeries, Selection, Category]} />
     <SeriesCollectionDirective>
       <SeriesDirective
         dataSource={data}
         xName="x"
         yName="y"
         type="StackingColumn"
         selectionStyle="chartSelection"
         fill="#7499BB"
       ></SeriesDirective>
       <SeriesDirective
         dataSource={data}
         xName="x"
         yName="y"
         type="StackingColumn"
         selectionStyle="chartSelection"
         fill="#422E5D"
       ></SeriesDirective>
     </SeriesCollectionDirective>
   </ChartComponent>
 );
};
export default SelectionChart;

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

Index.css

.chartSelection {
 fill: rgb(255, 165, 0);
}

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

Screenshot:

Before Selection After Selection
React chart stacking column before selection
React chart stacking column after selection

View Sample in Stackblitz

Conclusion

I hope you enjoyed learning how to select the entire stacking series point 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