Plug n Play Pie Chart in Flutter
Detalles del producto
Desarrollador
Hablar con el vendedor
Detalles del producto
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
- chartTitle
Type: String?
Displays a title at the center of the pie chart.
Default: null (no title). - startDegreeOffset
Type: double
Sets the starting degree of the chart.
Default: 250. - sectionsSpace
Type: double
Controls the spacing between sections of the chart.
Default: 0. - centerSpaceRadius
Type: double
Adjusts the radius of the space at the center of the chart.
Default: 100. - barRadius
Type: double
Changes the thickness of the chart's sections.
Default: 25. - chartTitleSize
Type: double
Controls the font size of the chart title.
Default: 20. - 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
- legendTitle
Type: String
Sets the title of the legend box.
Default: "Legend". - legendBoxRadius
Type: double
Adjusts the border radius of the legend box container.
Default: 16. - legendBoxColor
Type: Color
Controls the background color of the legend box.
Default: Color.fromARGB(75, 200, 200, 201). - width
Type: double?
Sets the width of the small color squares next to labels.
Default: 16. - height
Type: double?
Sets the height of the small color squares next to labels.
Default: 16. - 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.
Instrucciones de instalación
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.
Instrucciones de cambio y adaptación
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.
Estadísticas de precios
Este producto no cuenta con información disponible.