Articles in this section
Category / Section

How to render the Flutter chart with background image (SfCartesianChart) ?

1 min read

SfCartesianChart provides support for rendering the background image for the plot area. You can set the desired image as a background for the plot area using the plotAreaBackgroundImage property.

The following steps describe step by step procedure for adding the image to plot area of chart widget.

Step 1: Create a folder named as images in your application and copy the desired image.

Folder structure

 

Step 2: Then, add the asset section in the pubspec.yaml file.

Asset section

 

Step 3: Now, wrap the SfCartesianChart widget with Container widget, and then add the image to the Container widget.

@override
Widget build(BuildContext context) {
return Scaffold(
      body: Container(
          decoration: BoxDecoration(
            image: DecorationImage(
              image: AssetImage("images/texture.jpg"),
              fit: BoxFit.cover,
            ),
          ),
          child: SfCartesianChart(
              //Other configurations
              ),
        )
  );
}

 

 

Chart background image

 

View the sample in GitHub

 

 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied