搜尋套件、儲存庫與 APP 分類

pie_chart 封面
套件詳情v5.4.0

pie_chart

一個用於建立美麗餅圖並具有精彩動畫效果的 Flutter 套件。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
3.1萬
喜歡數
440
Pub 分數
140

安裝套件

flutter pub add pie_chart

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個專為創建視覺上吸引人的餅圖並帶有平滑動畫的 Flutter 套件。它讓開發者能夠輕鬆地將互動式且可自訂的餅圖整合到他們的跨平台應用程式中。該套件支援動態資料更新、多種圖表樣式與響應式設計,非常適合用於儀錶板、報告或分析介面中顯示比例資料。透過簡單的 API 集成,它能透過引人入勝的視覺反饋提升使用者體驗。

適用情境

  • 顯示資料比例
  • 建立儀表板小部件
  • 可視化調查結果
  • 產生報告圖形
  • 構建分析介面

主要特色

  • 平滑的動畫效果
  • 可自訂的圖表顏色
  • 響應式版面支援
  • 動態資料更新
  • 互動式觸控回應

適合對象

  • 應用中的資料可視化
  • 教育工具
  • 業務分析儀表板
  • 行動與Web應用程式
  • 簡單的統計報告

使用建議

  • 僅限二維餅圖
  • 不適合大型資料集
  • 包含多個切片時可能影響效能
  • 需要仔細選擇顏色以確保可讀性
  • 適用於中小型資料集

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Pie Chart Cirrus CI - Base Branch Build Status GitHub stars Twitter Follow GitHub last commit Website shields.ioOpen Source Love Discord

This Flutter package provides a Pie Chart Widget with cool animation.

More discussions on Discord: https://discord.gg/7byeCn7MGF

💻 Try LIVE Demo

Live Demo: https://apgapg.github.io/pie_chart/

piechart

💻 Installation

In the dependencies: section of your pubspec.yaml, add the following line:

Version

dependencies:
  pie_chart: <latest version>

❔ Usage

Import this class
import 'package:pie_chart/pie_chart.dart';
Usage is simple. Pie Chart is a widget and it just need a Map<String,double> as its data input.
PieChart
Map<String, double> dataMap = {
    "Flutter": 5,
    "React": 3,
    "Xamarin": 2,
    "Ionic": 2,
  };
- Simple Implementation
PieChart(dataMap: dataMap) 
- Full Implementation
PieChart(
      dataMap: dataMap,
      animationDuration: Duration(milliseconds: 800),
      chartLegendSpacing: 32,
      chartRadius: MediaQuery.of(context).size.width / 3.2,
      colorList: colorList,
      initialAngleInDegree: 0,
      chartType: ChartType.ring,
      ringStrokeWidth: 32,
      centerText: "HYBRID",
      legendOptions: LegendOptions(
        showLegendsInRow: false,
        legendPosition: LegendPosition.right,
        showLegends: true,
        legendShape: _BoxShape.circle,
        legendTextStyle: TextStyle(
          fontWeight: FontWeight.bold,
        ),
      ),
      chartValuesOptions: ChartValuesOptions(
        showChartValueBackground: true,
        showChartValues: true,
        showChartValuesInPercentage: false,
        showChartValuesOutside: false,
        decimalPlaces: 1,
      ),
      // gradientList: ---To add gradient colors---
      // emptyColorGradient: ---Empty Color gradient---
    )

⭐ Features

Control decimal places 'decimalPlaces'
chartValuesOptions: ChartValuesOptions(
  decimalPlaces: 1,
),
Change legend position with 'legendPosition'

PieChart PieChart PieChart PieChart

Change Chart shape to ring
chartType: ChartType.ring,
PieChart
chartType: ChartType.ring,
showChartValuesOutside: true,
PieChart
Gradient Colors

Pie Chart supports gradient as colors. Just pass gradientList instead of colorList to add gradient to chart colors.

final gradientList = <List<Color>>[
  [
    Color.fromRGBO(223, 250, 92, 1),
    Color.fromRGBO(129, 250, 112, 1),
  ],
  [
    Color.fromRGBO(129, 182, 205, 1),
    Color.fromRGBO(91, 253, 199, 1),
  ],
  [
    Color.fromRGBO(175, 63, 62, 1.0),
    Color.fromRGBO(254, 154, 92, 1),
  ]
];

// Pass gradient to PieChart
gradientList: gradientList,
emptyColorGradient: [
 Color(0xff6c5ce7),
 Colors.blue,
],
PieChart
Base Chart Color

Add a base pie-chart color via:

baseChartColor: Colors.grey

Full code:

class HomePage2 extends StatelessWidget {
  HomePage2({Key? key}) : super(key: key);

  final dataMap = <String, double>{
    "Flutter": 5,
  };

  final colorList = <Color>[
    Colors.greenAccent,
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Pie Chart 1"),
      ),
      body: Container(
        padding: EdgeInsets.symmetric(horizontal: 16),
        child: PieChart(
          dataMap: dataMap,
          chartType: ChartType.ring,
          baseChartColor: Colors.grey[300]!,
          colorList: colorList,
        ),
      ),
    );
  }
}
Total Value

To show chart arcs based on your total value, add totalValue option.

class HomePage2 extends StatelessWidget {
  HomePage2({Key? key}) : super(key: key);

  final dataMap = <String, double>{
    "Flutter": 5,
  };

  final colorList = <Color>[
    Colors.greenAccent,
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Pie Chart 1"),
      ),
      body: Container(
        padding: EdgeInsets.symmetric(horizontal: 16),
        child: PieChart(
          dataMap: dataMap,
          chartType: ChartType.ring,
          baseChartColor: Colors.grey[50]!.withOpacity(0.15),
          colorList: colorList,
          chartValuesOptions: ChartValuesOptions(
            showChartValuesInPercentage: true,
          ),
          totalValue: 20,
        ),
      ),
    );
  }
}
PieChart
Center Widget

Creates a new widget placed at pie chart center

centerWidget: Container(color: Colors.red, child: const Text("Center"))
PieChart

⭐ My Flutter Packages

  • json_table GitHub stars Create Flutter Json Table from json map directly.
  • avatar_glow GitHub stars Flutter Avatar Glow Widget with glowing animation.
  • search_widget GitHub stars Flutter Search Widget for selecting an option from list.
  • animating_location_pin GitHub stars Flutter Animating Location Pin Widget providing Animating Location Pin Widget which can be used while fetching device location.

⭐ My Flutter Apps

👍 Contribution

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -m 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

所屬分類

原始碼儲存庫

使用此套件的專案