Plug n Play Pie Chart in Flutter

Informações do produto

Sempre grátis
Aproveite os projetos de código-fonte grátis, exclusivamente para a comunidade PieceX.

Linguagem de programação

Usabilidade

Guia do usuário

Desenvolvedor

Auxle
Solicitar amostra de código Mensagem direta

Nov 23, 2024

Chat público

Detalhes do produto

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.

Instruções de instalação

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.

Instruções de alteração e adaptação

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.

Informações de preço

Nenhum dado disponível

Apenas visualização limitada


O produto real contém todos os arquivos e o código completo

Verificar dependências

Ver dependências externas do produto

Arquivo de amostra selecionado aleatoriamente

Estatísticas do arquivo do projeto

Hierarquia

Escolha um arquivo de amostra
X

Fique em contato

  • Obtenha dicas práticas para empresas e desenvolvedores.
  • Saiba mais sobre as necessidades da comunidade PieceX para projetos de código-fonte.
  • Seja o primeiro a conhecer os mais novos projetos de código gratuito da comunidade PieceX.
PieceX Logo