Plug n Play Pie Chart in Flutter

Product Information

Always Free
Enjoy source code projects for free, exclusively for the PieceX community.

Programming Language

Usability

User Guide

Developer

Auxle
Request Code Sample Direct message

Nov 23, 2024

Public chat

Product Details

CustomPieChart Widget Documentation


The CustomPieChart widget is a ready-to-use Flutter Pie Chart solution for interactive data visualization. It allows you to display data dynamically with minimal setup and offers customization options to suit your design needs.


Features


  • Displays data interactively with a Pie Chart.

  • Automatically assigns unique colors to data values.

  • Includes an optional legend box to map colors to labels.

  • Highly customizable parameters for styling and layout.



CustomPieChart Parameters


Required


  • data
    Type: List<Map<String, dynamic>>
    A list of key-value pairs representing the data to display.
    Example:

[


{'Label1': 40},


{'Label2': 60}


]


Optional


  1. chartTitle
    Type: String?
    Displays a title at the center of the pie chart.
    Default: null (no title).

  2. startDegreeOffset
    Type: double
    Sets the starting degree of the chart.
    Default: 250.

  3. sectionsSpace
    Type: double
    Controls the spacing between sections of the chart.
    Default: 0.

  4. centerSpaceRadius
    Type: double
    Adjusts the radius of the space at the center of the chart.
    Default: 100.

  5. barRadius
    Type: double
    Changes the thickness of the chart's sections.
    Default: 25.

  6. chartTitleSize
    Type: double
    Controls the font size of the chart title.
    Default: 20.

  7. showTitle
    Type: bool
    If true, displays labels for each section above the pie chart.
    Default: false.



Usage Example


CustomPieChart(


data: [


{'Hello': 50},


{'Bye': 50}


],


chartTitle: 'Testing',


showTitle: true,


startDegreeOffset: 250,


barRadius: 25,


)





Legend Widget Documentation


The Legend widget is an optional component that displays a legend box below the pie chart. It maps each color to its corresponding label for better data comprehension.


Legend Parameters


Required


  • data
    Type: List<Map<String, dynamic>>
    Same as the data parameter in CustomPieChart.

Optional


  1. legendTitle
    Type: String
    Sets the title of the legend box.
    Default: "Legend".

  2. legendBoxRadius
    Type: double
    Adjusts the border radius of the legend box container.
    Default: 16.

  3. legendBoxColor
    Type: Color
    Controls the background color of the legend box.
    Default: Color.fromARGB(75, 200, 200, 201).

  4. width
    Type: double?
    Sets the width of the small color squares next to labels.
    Default: 16.

  5. height
    Type: double?
    Sets the height of the small color squares next to labels.
    Default: 16.

  6. colorRadius
    Type: double?
    Adjusts the border radius of the small color squares.
    Default: 0 (normal squares).



Usage Example


Legend(


data: [


{'Hello': 50},


{'Bye': 50}


],


legendTitle: 'My Legend',


colorRadius: 5,


legendBoxColor: Colors.grey[200]!,


)




Key Benefits


  • Minimal setup with data as the only required parameter.

  • Flexible styling for both the pie chart and the legend box.

  • Simplifies the process of creating interactive, visually appealing dashboards.

Feel free to implement and customize it for your project!


Displays data interactively with a Pie Chart.

Automatically assigns unique colors to data values.

Includes an optional legend box to map colors to labels.

Highly customizable parameters for styling and layout.

Requires only the data.

Installation Instructions

Step 1: Install `fl_chart` Package
1. Open your Flutter project's `pubspec.yaml` file.
2. Add the following line under the `dependencies` section:
dependencies:
fl_chart: ^0.48.0 # Use the latest version available
3. Run the following command in your terminal to install the package:
flutter pub get

Step 2: Add the Custom Code File
1. Download the provided code file containing the CustomPieChart and Legend widgets.
2. Place the file into the `lib` directory of your Flutter project. You can create a folder (e.g., `lib/widgets`) to organize it better.

Step 3: Import the Widgets
To use the CustomPieChart and Legend widgets in your project:
1. Import your custom code file into the desired Dart file:
import 'package:project_name/custom_pie_chart.dart';

Or simply call the constructor CustomPieChart() or Legend(), the Code Editor should be able to automatically import the package, if the code file is properly placed in the project.

Change and Adaptation Instructions

If the provided custom methods is not enough, you can always go to the source code file and make changes in the CustomPieChart class, if you want to change the functionality or look of your Pie Chart.

If you want to change the way Legend is displayed, then you can change it in the Legend class. The key-value pair in Legend is displayed using LegendItem class below Legend class.

Price Information

No available data

Limited Preview Only


Real Product Contains All Files And Full Code

Check dependencies

See product external dependencies

Randomly Selected Sample File

Project File Statistics

Hierarchy

Choose a sample file
X

Stay in touch

  • Get Practical Tips For Business and Developers.
  • Learn about PieceX Community Needs for Source Code Projects.
  • Be the First to Know PieceX Newest Free Community Code Projects.
PieceX Logo