Articles in this section
Category / Section

How to render the React Chart with background image?

3 mins read

This article explains how to render chart with background image in the React Chart.

Customize the chart background with an image

You can set the desired image as a background for the chart by using the backgroundImage property. The background image of the chart accepts a string value as a URL link or the location of an image.

In the following code example, the chart background is customized with wheat image.

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 ChartTooltipTemplate = () => {
 return (
       <ChartComponent
         id="chartTooltip"
         backgroundImage="https://ej2.syncfusion.com/react/demos/src/chart/images/wheat.png"
         primaryXAxis={{
           valueType: 'Category'
         }}
         primaryYAxis={{
           title: 'Billion Bushels'
         }}
         title="USA Wheat Production"
       >
         <Inject services={[LineSeries, Category]} />
         <SeriesCollectionDirective>
           <SeriesDirective
             dataSource={data1}
             xName="x"
             yName="y"
             type="Line"
           />
         </SeriesCollectionDirective>
       </ChartComponent>
 );
};
export default ChartTooltipTemplate;

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

The following screenshot portrays the results of the code snippet mentioned above.

Screenshot:

React chart background image

View Sample in Stackblitz

Conclusion

I hope you enjoyed learning how to render chart with background image 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