How to set the opacity of the React Chart?
This article explains how to set the opacity of the React Chart.
Customize the opacity of the series
You can easily customize the opacity of the series by using the opacity property. By default, the opacity of the chart series is 1.
In the following code example, the opacity of the series is set to 0.5 and the series fill is set to green.
Index.js
import { createRoot } from 'react-dom/client';
import * as React from 'react';
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Category, SplineAreaSeries,
Tooltip } from '@syncfusion/ej2-react-charts';
const Spline = () => {
return (
<ChartComponent
id="charts"
>
<Inject services={[SplineAreaSeries, Category, Tooltip]} />
<SeriesCollectionDirective>
<SeriesDirective
dataSource={data1}
xName="x"
yName="y"
type="SplineArea"
fill="green"
border={{ width: 2, color: 'black' }}
opacity={0.5}
/>
</SeriesCollectionDirective>
</ChartComponent>
);
};
export default Spline;
const root = createRoot(document.getElementById('sample'));
root.render(<Spline />);
The following screenshot illustrate the output of the above code snippet.
Screenshot:
Conclusion
I hope you enjoyed learning how to set the opacity of 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!