Plug n Play Pie Chart in Flutter

제품 정보

항상 무료
PieceX 커뮤니티만을 위한 소스 코드 프로젝트를 무료로 즐겨보세요.

프로그래밍 언어

유용성

사용 설명서 문서

개발자

Auxle
코드 샘플 요청 다이렉트 메세지

Nov 23, 2024

공개 채팅

제품 세부 정보

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.

설치 지침

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.

변경 및 적응 지침

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.

가격 정보

이 제품에는 사용 가능한 정보가 없습니다.

제한된 미리 보기


실제 제품에는 모든 파일과 전체 코드가 포함되어 있습니다.

종속성 확인

제품 외부 종속성 보기

무작위로 선택한 샘플 파일

프로젝트 파일 통계

계층구조

샘플 파일 선택
X

문의하기

  • 비즈니스 개발자를 위한 최신 정보를 원하십니까? 소스 코드 프로젝트에 대한 PieceX 커뮤니티의 요구사항을 알아보세요. PieceX의 최신 무료 커뮤니티 코드를 빠르게 알려드립니다.
PieceX Logo