How to change the data point selection color in React Chart?
This article explains how to change the data point selection color in the React Chart.
Change the data point selection color
In data visualization, customizing the appearance of selected points or series is crucial, and it can be achieved by using the selectionStyle property. This property allows you to apply custom styles to selected points or series, enhancing the visual appeal and readability of the data.
In the following code example, the color of the data point was changed when selecting the point using custom styles.
Index.js
import * as React from 'react';
import { createRoot } from 'react-dom/client';
import './index.css';
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Category, ColumnSeries, Selection
} from '@syncfusion/ej2-react-charts';
const SelectionChart = () => {
return (
<chartcomponent id="charts">
<inject services="{[ColumnSeries," selection,="" category]}="">
<seriescollectiondirective>
<seriesdirective datasource="{data1}" xname="country" yname="gold" name="Gold" type="Column" selectionstyle="chartSelection1" fill="orange"></seriesdirective>
</seriescollectiondirective>
</inject></chartcomponent>
);
};
export default SelectionChart;
const root = createRoot(document.getElementById('sample'));
root.render(<selectionchart>);
Index.css
.chartSelection1 {
fill: violet;
}
The code snippet below demonstrates how to change the color of the selected data point.
Screenshot:
Refer to the working sample for additional details and implementation: View Sample in Stackblitz
Conclusion
We hope you enjoyed learning how to change the data point selection color in React Chart.
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, BoldDesk Support, or feedback portal. We are always happy to assist you!