diff --git a/lib/new_views/pages/land_page/dashboard_fragments/progress_fragment.dart b/lib/new_views/pages/land_page/dashboard_fragments/progress_fragment.dart index 4866cf96..c9d3c222 100644 --- a/lib/new_views/pages/land_page/dashboard_fragments/progress_fragment.dart +++ b/lib/new_views/pages/land_page/dashboard_fragments/progress_fragment.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:pie_chart/pie_chart.dart'; + +// import 'package:test_sa/pie_chart/pie_chart.dart'; import 'package:provider/provider.dart'; import 'package:test_sa/controllers/providers/api/all_requests_provider.dart'; import 'package:test_sa/extensions/context_extension.dart'; @@ -8,7 +9,8 @@ import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/new_views/pages/land_page/widgets/request_item_view_list.dart'; - +import 'package:syncfusion_flutter_charts/charts.dart'; +import 'package:syncfusion_flutter_charts/sparkcharts.dart'; import '../../../../controllers/providers/api/user_provider.dart'; import '../../../../models/enums/user_types.dart'; @@ -23,56 +25,68 @@ class ProgressFragment extends StatelessWidget { bool isCurrentUserNotEngineer = (_userProvider.user.type != UsersTypes.engineer); return Consumer( builder: (context, snapshot, _) { - Map statuses = { - "Completed": snapshot.completedRequests?.requestsDetails?.length?.toDouble() ?? 0.0, - "In Progress": snapshot.inProgressRequests?.requestsDetails?.length?.toDouble() ?? 0.0, - // "Open": snapshot.openRequests?.requestsDetails?.length?.toDouble() ?? 0.0, - }; - if (isCurrentUserNotEngineer) { - statuses["Open"] = snapshot.openRequests?.requestsDetails?.length?.toDouble() ?? 0.0; - } int total = (snapshot.completedRequests?.requestsDetails?.length ?? 0) + (snapshot.inProgressRequests?.requestsDetails?.length ?? 0) + (isCurrentUserNotEngineer ? (snapshot.openRequests?.requestsDetails?.length ?? 0) : 0); + final List chartData = [ + ChartData('Completed', snapshot.completedRequests?.requestsDetails?.length?.toDouble() ?? 0.0, AppColor.greenStatus(context)), + ChartData('In Progress', snapshot.inProgressRequests?.requestsDetails?.length?.toDouble() ?? 0.0, AppColor.yellowStatus(context)), + ]; + + if (isCurrentUserNotEngineer) { + chartData.insert(1, ChartData('Open', snapshot.openRequests?.requestsDetails?.length?.toDouble() ?? 0.0, AppColor.blueStatus(context))); + } + return Column( children: [ AspectRatio( aspectRatio: 398 / 237, - child: PieChart( - dataMap: statuses, - animationDuration: const Duration(milliseconds: 500), - chartRadius: 190.toScreenWidth, - colorList: [ - AppColor.greenStatus(context), - AppColor.yellowStatus(context), - AppColor.blueStatus(context), + child: Stack( + alignment: Alignment.center, + children: [ + SfCircularChart( + tooltipBehavior: TooltipBehavior( + enable: true, + // elevation: 2, + color: context.isDark ? Color(0xFF111427) : Color(0xffF7F9FB), + textStyle: context.isDark ? null : TextStyle(color: Colors.black87, fontSize: 12), + ), + legend: Legend( + //isVisible: true, + ), + series: [ + DoughnutSeries( + dataSource: chartData, + radius: "110%", + innerRadius: "60%", + pointColorMapper: (ChartData data, _) => data.color, + xValueMapper: (ChartData data, _) => data.x, + yValueMapper: (ChartData data, _) => data.y, + dataLabelMapper: (ChartData data, _) => data.x, + dataLabelSettings: DataLabelSettings( + isVisible: true, + textStyle: TextStyle(color: context.isDark ? Colors.white : Colors.black87, fontSize: 12), + labelPosition: ChartDataLabelPosition.outside, + //useSeriesColor: true, + ), + ) + ]).toShimmer(isShow: snapshot.isOpenLoading || snapshot.isInProgressLoading || snapshot.isCompleteLoading, radius: 300).paddingAll(12).toShadowContainer(context), + Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + context.translation.total, + style: AppTextStyles.heading5.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50), + ), + Text( + "$total", + style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), + ), + ], + ), ], - initialAngleInDegree: 270, - chartType: ChartType.ring, - ringStrokeWidth: 40.toScreenWidth, - sideTextStyle: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), - centerWidget: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - context.translation.total, - style: AppTextStyles.heading5.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50), - ), - Text( - "$total", - style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), - ), - ], - ), - legendOptions: const LegendOptions(showLegends: false), - chartValuesOptions: ChartValuesOptions( - chartValueBackgroundColor: Theme.of(context).scaffoldBackgroundColor, - showChartValuesInPercentage: true, - chartValueStyle: AppTextStyles.bodyText2.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral60), - showChartValuesOutside: true, - ), - ).toShimmer(isShow: snapshot.isOpenLoading || snapshot.isInProgressLoading || snapshot.isCompleteLoading, radius: 300).paddingAll(12).toShadowContainer(context), + ), ).paddingOnly(start: 16, end: 16, bottom: 16), DefaultTabController( length: isCurrentUserNotEngineer ? 3 : 2, @@ -116,32 +130,12 @@ class ProgressFragment extends StatelessWidget { }, ); } -// -// Widget requestItemView(List list, bool isLoading) { -// return ListView.separated( -// padding: const EdgeInsets.all(16), -// itemBuilder: (cxt, index) { -// if (isLoading) return SizedBox().toRequestShimmer(cxt, isLoading); -// bool isServiceRequest = list[index].nameOfType == "ServiceRequest"; -// bool isGasRefill = list[index].nameOfType == "GasRefill"; -// bool isAssetTransfer = list[index].nameOfType == "AssetTransfer"; -// bool isPPMs = list[index].nameOfType == "PPMs"; -// -// return isServiceRequest -// ? ServiceRequestItemView(list[index]) -// : isGasRefill -// ? GasRefillItemView(list[index]) -// : isPPMs -// ? PpmItemView(list[index]) -// : isAssetTransfer -// ? AssetItemView(list[index]) -// : Container( -// height: 100, -// width: double.infinity, -// color: Colors.grey, -// ); -// }, -// separatorBuilder: (cxt, index) => 8.height, -// itemCount: isLoading ? 6 : list.length); -// } +} + +class ChartData { + ChartData(this.x, this.y, this.color); + + final String x; + final double y; + final Color color; } diff --git a/packages/edited_pie_chart/CHANGELOG.md b/packages/edited_pie_chart/CHANGELOG.md deleted file mode 100644 index 533dfd77..00000000 --- a/packages/edited_pie_chart/CHANGELOG.md +++ /dev/null @@ -1,58 +0,0 @@ -## [4.0.1] -* Fix README.md for broken images link - -## [4.0.0] **Breaking** -* Wrap different parameters in chartValuesOptions, legendOptions -* Fix number of issues - -## [3.1.1] -* Fix [#22](https://github.com/apgapg/pie_chart/issues/22) showLegends = false causes exception. - -## [3.1.0] -* Add ring shape pie chart support - -## [3.0.0] **Breaking** -* Migrate to AndroidX -* Add dark mode theme -* Remove color from default legendStyle to support dark mode -* Add enum LegendPosition to align chart legend **Breaking** -* Restructure whole project. Optimize code. Code Cleanup - -Thanks [@xsahil03x](https://github.com/xsahil03x) for these changes - -## [2.0.0] -* Fix padding, margin **Breaking** -* Fix error when parent is row -* Adapt to screen size **Breaking** -* Override chartRadius when screen is smaller compare to chartRadius **Breaking** -* Update example with macos and web support - -## [1.3.0] -* Center text to sector center-line -* Add text labels - -## [1.2.0] -* Merge [#12](https://github.com/apgapg/pie_chart/issues/12) Added option for showing decimal places in chart values. Thanks [@VB10](https://github.com/VB10) for PR - -## [1.1.0] -* Merge [#11](https://github.com/apgapg/pie_chart/issues/11) Added option for changing initial angle of pie chart. Thanks [@mschneider](https://github.com/mschneider) for PR - -## [1.0.0] -* Added [#8](https://github.com/apgapg/pie_chart/issues/8) Added option for showing chart values outside the pie chart [@guyzk](https://github.com/guyzk) -* Added [#7](https://github.com/apgapg/pie_chart/issues/7) Hide 0 values on pie chart. Thanks [@guyzk](https://github.com/https://github.com/guyzk) -* Added legend fontFamily support. Thanks [@MahdiPishguy](https://github.com/MahdiPishguy) for PR - -## [0.9.0] -* Fixes [#5](https://github.com/apgapg/pie_chart/issues/5) Added custom colorlist optional parameter. Thanks [@SJente](https://github.com/SJente) -* Fixes [#3](https://github.com/apgapg/pie_chart/issues/3) Update PieChart when data changes. Thanks [@leehuwuj](https://github.com/https://github.com/leehuwuj) -* Fixes [#2](https://github.com/apgapg/pie_chart/issues/2) Added showLegends bool as optional Parameter. Thanks [@cuitao1988](https://github.com/https://github.com/cuitao1988) -* Fixes Exception when data length was greater than 5 -* Added key to PieChart - -## [0.8.0] -* Update README.md -* Format code -* Update min Dart SDK version -Thanks [@xsahil03x](https://github.com/xsahil03x) for this PR - -## [0.7.0] - Initial Release diff --git a/packages/edited_pie_chart/lib/pie_chart.dart b/packages/edited_pie_chart/lib/pie_chart.dart deleted file mode 100644 index 0a2e7afa..00000000 --- a/packages/edited_pie_chart/lib/pie_chart.dart +++ /dev/null @@ -1,6 +0,0 @@ -library pie_chart; - -export 'src/chart_values_options.dart'; -export 'src/legend_options.dart'; -export 'src/pie_chart.dart'; -export 'src/utils.dart' hide defaultColorList; diff --git a/packages/edited_pie_chart/lib/src/chart_painter.dart b/packages/edited_pie_chart/lib/src/chart_painter.dart deleted file mode 100644 index 0dfd53f3..00000000 --- a/packages/edited_pie_chart/lib/src/chart_painter.dart +++ /dev/null @@ -1,154 +0,0 @@ -import 'dart:math' as math; - -import 'package:flutter/material.dart'; -import 'package:pie_chart/pie_chart.dart'; - -class PieChartPainter extends CustomPainter { - List _paintList = []; - List _subParts; - List _subTitles; - double _total = 0; - double _totalAngle = math.pi * 2; - - final TextStyle chartValueStyle; - final Color chartValueBackgroundColor; - final double initialAngle; - final bool showValuesInPercentage; - final bool showChartValues; - final bool showChartValuesOutside; - final int decimalPlaces; - final bool showChartValueLabel; - final ChartType chartType; - final Function formatChartValues; - final double strokeWidth; - final bool selected; - final List colorList; - double _prevAngle = 0; - final TextStyle sideTextStyle; - - PieChartPainter( - double angleFactor, - this.showChartValues, - this.showChartValuesOutside, - this.colorList, { - this.chartValueStyle, - this.chartValueBackgroundColor, - List values, - List titles, - this.initialAngle, - this.showValuesInPercentage, - this.decimalPlaces, - this.showChartValueLabel, - this.chartType, - this.formatChartValues, - this.strokeWidth, - this.selected = false, - this.sideTextStyle, - }) { - for (int i = 0; i < values.length; i++) { - final paint = Paint()..color = getColor(colorList, i); - if (chartType == ChartType.ring) { - paint.style = PaintingStyle.stroke; - paint.strokeWidth = strokeWidth; - } - - _paintList.add(paint); - } - _totalAngle = angleFactor * math.pi * 2; - _subParts = values; - _subTitles = titles; - _total = values.fold(0, (v1, v2) => v1 + v2); - } - - @override - void paint(Canvas canvas, Size size) { - final side = size.width < size.height ? size.width : size.height; - _prevAngle = initialAngle * math.pi / 180; - for (int i = 0; i < _subParts.length; i++) { - canvas.drawArc( - Rect.fromLTWH(0.0, 0.0, side, size.height), - _prevAngle, - (((_totalAngle) / _total) * _subParts[i]), - chartType == ChartType.disc ? true : false, - _paintList[i], - ); - final radius = showChartValuesOutside ? (side / 2) + 16 : side / 3; - final x = (radius) * math.cos(_prevAngle + ((((_totalAngle) / _total) * _subParts[i]) / 2)); - final y = (radius) * math.sin(_prevAngle + ((((_totalAngle) / _total) * _subParts[i]) / 2)); - if (_subParts.elementAt(i).toInt() != 0) { - final value = formatChartValues != null ? formatChartValues(_subParts.elementAt(i)) : _subParts.elementAt(i).toStringAsFixed(this.decimalPlaces); - -// final name = showValuesInPercentage -// ? (((_subParts.elementAt(i) / _total) * 100) -// .toStringAsFixed(this.decimalPlaces) + -// '%') -// : value; -// final name = showValuesInPercentage ? (((_subParts.elementAt(i) / _total) * 100).toStringAsFixed(this.decimalPlaces) + '%') : _subTitles.elementAt(i); - - if (showChartValues) { - final name = "${_subTitles[i]} " + (showValuesInPercentage ? (((_subParts.elementAt(i) / _total) * 100).toStringAsFixed(this.decimalPlaces) + '%') : value); - var yLabel = y > size.width ? y + 40 : y + 10; - var xLabel = (y > size.width ? x - y : x * 1.6) - 15; - var yPopup = y - 8; - if (_subParts[i] <= (_total / _subParts.length)) { - yLabel = y + 8; - xLabel *= 1.1; - yPopup *= 1.25; - } - - if (selected) _drawLabel(canvas, name, x, yPopup, side, true, statusColor: getColor(colorList, i)); - _drawLabel(canvas, _subTitles[i], xLabel, yLabel, side + 8, false); - } - } - _prevAngle = _prevAngle + (((_totalAngle) / _total) * _subParts[i]); - } - } - - void _drawLabel(Canvas canvas, String name, double x, double y, double side, bool withBackground, {Color statusColor = Colors.white}) { - TextSpan span = TextSpan( - style: withBackground ? chartValueStyle : sideTextStyle, - text: name, - ); - TextPainter tp = TextPainter( - text: span, - textAlign: TextAlign.center, - textDirection: TextDirection.ltr, - ); - tp.layout(); - - if (withBackground && showChartValueLabel) { - //Draw text background box - final rect = Rect.fromCenter( - center: Offset((side / 2 + (x + 16)), (side / 2 + y)), - width: tp.width + 45, - height: tp.height + 16, - ); - final rect2 = Rect.fromCenter( - center: Offset( - (side / 2 + x) - ((tp.width - 16) / 2), - (side / 2 + y) - ((tp.height - 16) / 2), - ), - width: 12, - height: 12, - ); - final rRect = RRect.fromRectAndRadius(rect, const Radius.circular(8)); - final rRect2 = RRect.fromRectAndRadius(rect2, const Radius.circular(1)); - final paint = Paint() - ..color = chartValueBackgroundColor ?? Colors.grey[200] - ..style = PaintingStyle.fill; - canvas.drawRRect(rRect, paint); - canvas.drawRRect(rRect2, paint..color = statusColor); - } - //Finally paint the text above box - tp.paint( - canvas, - Offset( - (side / 2 + x) - ((tp.width - 50) / 2), - (side / 2 + y) - ((tp.height) / 2), - ), - ); - } - - @override - bool shouldRepaint(PieChartPainter oldDelegate) => selected != oldDelegate.selected; -} diff --git a/packages/edited_pie_chart/lib/src/chart_values_options.dart b/packages/edited_pie_chart/lib/src/chart_values_options.dart deleted file mode 100644 index feec3015..00000000 --- a/packages/edited_pie_chart/lib/src/chart_values_options.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:pie_chart/pie_chart.dart'; -import 'package:pie_chart/src/utils.dart'; - -class ChartValuesOptions { - final bool showChartValueBackground; - final int decimalPlaces; - final bool showChartValuesInPercentage; - final bool showChartValues; - final bool showChartValuesOutside; - final Color chartValueBackgroundColor; - final TextStyle chartValueStyle; - - const ChartValuesOptions({ - this.showChartValueBackground = true, - this.decimalPlaces = 1, - this.chartValueBackgroundColor, - this.showChartValuesInPercentage = false, - this.chartValueStyle = defaultChartValueStyle, - this.showChartValues = true, - this.showChartValuesOutside = false, - }); -} diff --git a/packages/edited_pie_chart/lib/src/legend.dart b/packages/edited_pie_chart/lib/src/legend.dart deleted file mode 100644 index be052197..00000000 --- a/packages/edited_pie_chart/lib/src/legend.dart +++ /dev/null @@ -1,48 +0,0 @@ -import 'package:flutter/material.dart'; - -class Legend extends StatelessWidget { - Legend({ - @required this.title, - @required this.color, - @required this.style, - @required this.legendShape, - }); - - final String title; - final Color color; - final TextStyle style; - final BoxShape legendShape; - - @override - Widget build(BuildContext context) { - return Row( - mainAxisAlignment: MainAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Container( - margin: EdgeInsets.symmetric(vertical: 2.0), - height: 20.0, - width: 18.0, - decoration: BoxDecoration( - shape: legendShape, - color: color, - ), - ), - SizedBox( - width: 8.0, - ), - Flexible( - fit: FlexFit.loose, - child: Text( - title, - style: style, - softWrap: true, - ), - ), - SizedBox( - width: 8.0, - ), - ], - ); - } -} diff --git a/packages/edited_pie_chart/lib/src/legend_options.dart b/packages/edited_pie_chart/lib/src/legend_options.dart deleted file mode 100644 index f3d17370..00000000 --- a/packages/edited_pie_chart/lib/src/legend_options.dart +++ /dev/null @@ -1,19 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:pie_chart/pie_chart.dart'; -import 'package:pie_chart/src/utils.dart'; - -class LegendOptions { - final bool showLegends; - final bool showLegendsInRow; - final TextStyle legendTextStyle; - final BoxShape legendShape; - final LegendPosition legendPosition; - - const LegendOptions({ - this.showLegends = true, - this.showLegendsInRow = false, - this.legendTextStyle = defaultLegendStyle, - this.legendShape = BoxShape.circle, - this.legendPosition = LegendPosition.right, - }); -} diff --git a/packages/edited_pie_chart/lib/src/pie_chart.dart b/packages/edited_pie_chart/lib/src/pie_chart.dart deleted file mode 100644 index 71810bdf..00000000 --- a/packages/edited_pie_chart/lib/src/pie_chart.dart +++ /dev/null @@ -1,266 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:pie_chart/pie_chart.dart'; - -import 'chart_painter.dart'; -import 'legend.dart'; -import 'utils.dart'; - -enum LegendPosition { top, bottom, left, right } - -enum ChartType { disc, ring } - -class PieChart extends StatefulWidget { - const PieChart({ - @required this.dataMap, - this.chartType = ChartType.disc, - this.chartRadius, - this.animationDuration, - this.chartLegendSpacing = 48, - this.colorList = defaultColorList, - this.initialAngleInDegree = 0.0, - this.formatChartValues, - this.centerWidget, - this.ringStrokeWidth = 20.0, - this.legendOptions = const LegendOptions(), - this.chartValuesOptions = const ChartValuesOptions(), - this.sideTextStyle, - Key key, - }) : super(key: key); - - final Map dataMap; - final ChartType chartType; - final double chartRadius; - final Duration animationDuration; - final double chartLegendSpacing; - final List colorList; - final double initialAngleInDegree; - final Function formatChartValues; - final Widget centerWidget; - final double ringStrokeWidth; - final LegendOptions legendOptions; - final ChartValuesOptions chartValuesOptions; - final TextStyle sideTextStyle; - - @override - _PieChartState createState() => _PieChartState(); -} - -class _PieChartState extends State with SingleTickerProviderStateMixin { - Animation animation; - AnimationController controller; - double _animFraction = 0.0; - bool _selected = false; - - List legendTitles; - List legendValues; - - void initLegends() { - legendTitles = widget.dataMap.keys.toList(growable: false); - } - - void initValues() { - legendValues = widget.dataMap.values.toList(growable: false); - } - - void initData() { - assert( - widget.dataMap != null && widget.dataMap.isNotEmpty, - "dataMap passed to pie chart cant be null or empty", - ); - initLegends(); - initValues(); - } - - @override - void initState() { - super.initState(); - initData(); - controller = AnimationController( - duration: widget.animationDuration ?? const Duration(milliseconds: 800), - vsync: this, - ); - final Animation curve = CurvedAnimation( - parent: controller, - curve: Curves.decelerate, - ); - animation = Tween(begin: 0, end: 1).animate(curve) - ..addListener(() { - _animFraction = animation.value; - setState(() {}); - }); - controller.forward(); - } - - Widget _getChart() { - return Flexible( - child: Stack( - alignment: Alignment.center, - children: [ - LayoutBuilder( - builder: (_, c) => SizedBox( - height: widget.chartRadius != null - ? c.maxWidth < widget.chartRadius - ? c.maxWidth - : widget.chartRadius - : null, - child: GestureDetector( - onTapDown: (details) { - _selected = !_selected; - setState(() {}); - }, - child: Stack( - children: [ - if (_selected) - CustomPaint( - painter: PieChartPainter( - _animFraction, - widget.chartValuesOptions.showChartValues, - widget.chartValuesOptions.showChartValuesOutside, - widget.colorList.map((e) => e.withOpacity(0.4)).toList(), - chartValueStyle: widget.chartValuesOptions.chartValueStyle, - chartValueBackgroundColor: widget.chartValuesOptions.chartValueBackgroundColor, - values: legendValues, - titles: legendTitles, - initialAngle: widget.initialAngleInDegree, - showValuesInPercentage: widget.chartValuesOptions.showChartValuesInPercentage, - decimalPlaces: widget.chartValuesOptions.decimalPlaces, - showChartValueLabel: widget.chartValuesOptions.showChartValueBackground, - chartType: widget.chartType, - formatChartValues: widget.formatChartValues, - strokeWidth: widget.ringStrokeWidth + 10, - sideTextStyle: widget.sideTextStyle, - ), - child: const AspectRatio(aspectRatio: 1), - ), - CustomPaint( - painter: PieChartPainter( - _animFraction, - widget.chartValuesOptions.showChartValues, - widget.chartValuesOptions.showChartValuesOutside, - widget.colorList, - chartValueStyle: widget.chartValuesOptions.chartValueStyle, - chartValueBackgroundColor: widget.chartValuesOptions.chartValueBackgroundColor, - values: legendValues, - titles: legendTitles, - initialAngle: widget.initialAngleInDegree, - showValuesInPercentage: widget.chartValuesOptions.showChartValuesInPercentage, - decimalPlaces: widget.chartValuesOptions.decimalPlaces, - showChartValueLabel: widget.chartValuesOptions.showChartValueBackground, - chartType: widget.chartType, - formatChartValues: widget.formatChartValues, - strokeWidth: widget.ringStrokeWidth, - selected: _selected, - sideTextStyle: widget.sideTextStyle, - ), - child: const AspectRatio(aspectRatio: 1), - ), - ], - ), - ), - ), - ), - if (widget.centerWidget != null) widget.centerWidget, - ], - ), - ); - } - - Widget _getPieChart() { - switch (widget.legendOptions.legendPosition) { - case LegendPosition.top: - return Column( - mainAxisSize: MainAxisSize.min, - children: [ - _getLegend(padding: EdgeInsets.only(bottom: widget.chartLegendSpacing)), - _getChart(), - ], - ); - - case LegendPosition.bottom: - return Column( - mainAxisSize: MainAxisSize.min, - children: [ - _getChart(), - _getLegend(padding: EdgeInsets.only(top: widget.chartLegendSpacing)), - ], - ); - case LegendPosition.left: - return Row( - mainAxisSize: MainAxisSize.min, - children: [ - _getLegend(padding: EdgeInsets.only(right: widget.chartLegendSpacing)), - _getChart(), - ], - ); - case LegendPosition.right: - return Row( - mainAxisSize: MainAxisSize.min, - children: [ - _getChart(), - _getLegend(padding: EdgeInsets.only(left: widget.chartLegendSpacing)), - ], - ); - default: - return Row( - mainAxisSize: MainAxisSize.min, - children: [ - _getChart(), - _getLegend( - padding: EdgeInsets.only( - left: widget.chartLegendSpacing, - ), - ), - ], - ); - } - } - - _getLegend({EdgeInsets padding}) { - if (widget.legendOptions.showLegends) { - return Padding( - padding: padding, - child: Wrap( - direction: widget.legendOptions.showLegendsInRow ? Axis.horizontal : Axis.vertical, - runSpacing: 8, - crossAxisAlignment: WrapCrossAlignment.start, - children: legendTitles - .map( - (item) => Legend( - title: item, - color: getColor( - widget.colorList, - legendTitles.indexOf(item), - ), - style: widget.legendOptions.legendTextStyle, - legendShape: widget.legendOptions.legendShape, - ), - ) - .toList(), - ), - ); - } else { - return const SizedBox(height: 0, width: 0); - } - } - - @override - Widget build(BuildContext context) { - return Container( - alignment: Alignment.center, - padding: const EdgeInsets.all(8.0), - child: _getPieChart(), - ); - } - - @override - void didUpdateWidget(PieChart oldWidget) { - initData(); - super.didUpdateWidget(oldWidget); - } - - @override - void dispose() { - controller?.dispose(); - super.dispose(); - } -} diff --git a/packages/edited_pie_chart/lib/src/utils.dart b/packages/edited_pie_chart/lib/src/utils.dart deleted file mode 100644 index 8eebb079..00000000 --- a/packages/edited_pie_chart/lib/src/utils.dart +++ /dev/null @@ -1,31 +0,0 @@ -import 'package:flutter/material.dart'; - -const defaultChartValueStyle = TextStyle( - fontSize: 12, - fontWeight: FontWeight.bold, - color: Colors.black, -); - -const defaultLegendStyle = TextStyle( - fontSize: 12, - fontWeight: FontWeight.bold, -); - -const List defaultColorList = [ - Color(0xFFff7675), - Color(0xFF74b9ff), - Color(0xFF55efc4), - Color(0xFFffeaa7), - Color(0xFFa29bfe), - Color(0xFFfd79a8), - Color(0xFFe17055), - Color(0xFF00b894), -]; - -Color getColor(List colorList, int index) { - if (index > (colorList.length - 1)) { - final newIndex = index % (colorList.length - 1); - return colorList.elementAt(newIndex); - } - return colorList.elementAt(index); -} diff --git a/packages/edited_pie_chart/pubspec.lock b/packages/edited_pie_chart/pubspec.lock deleted file mode 100644 index 7a7d0e5f..00000000 --- a/packages/edited_pie_chart/pubspec.lock +++ /dev/null @@ -1,164 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - async: - dependency: transitive - description: - name: async - sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 - url: "https://pub.dev" - source: hosted - version: "2.10.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - characters: - dependency: transitive - description: - name: characters - sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c - url: "https://pub.dev" - source: hosted - version: "1.2.1" - clock: - dependency: transitive - description: - name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf - url: "https://pub.dev" - source: hosted - version: "1.1.1" - collection: - dependency: transitive - description: - name: collection - sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 - url: "https://pub.dev" - source: hosted - version: "1.17.0" - fake_async: - dependency: transitive - description: - name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" - url: "https://pub.dev" - source: hosted - version: "1.3.1" - flutter: - dependency: "direct main" - description: flutter - source: sdk - version: "0.0.0" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - js: - dependency: transitive - description: - name: js - sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" - url: "https://pub.dev" - source: hosted - version: "0.6.5" - matcher: - dependency: transitive - description: - name: matcher - sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" - url: "https://pub.dev" - source: hosted - version: "0.12.13" - material_color_utilities: - dependency: transitive - description: - name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 - url: "https://pub.dev" - source: hosted - version: "0.2.0" - meta: - dependency: transitive - description: - name: meta - sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" - url: "https://pub.dev" - source: hosted - version: "1.8.0" - path: - dependency: transitive - description: - name: path - sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b - url: "https://pub.dev" - source: hosted - version: "1.8.2" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - source_span: - dependency: transitive - description: - name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 - url: "https://pub.dev" - source: hosted - version: "1.9.1" - stack_trace: - dependency: transitive - description: - name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 - url: "https://pub.dev" - source: hosted - version: "1.11.0" - stream_channel: - dependency: transitive - description: - name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - string_scanner: - dependency: transitive - description: - name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" - url: "https://pub.dev" - source: hosted - version: "1.2.0" - term_glyph: - dependency: transitive - description: - name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 - url: "https://pub.dev" - source: hosted - version: "1.2.1" - test_api: - dependency: transitive - description: - name: test_api - sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 - url: "https://pub.dev" - source: hosted - version: "0.4.16" - vector_math: - dependency: transitive - description: - name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" - url: "https://pub.dev" - source: hosted - version: "2.1.4" -sdks: - dart: ">=2.18.0 <3.0.0" diff --git a/packages/edited_pie_chart/pubspec.yaml b/packages/edited_pie_chart/pubspec.yaml deleted file mode 100644 index 109577b7..00000000 --- a/packages/edited_pie_chart/pubspec.yaml +++ /dev/null @@ -1,51 +0,0 @@ -name: pie_chart -description: A Flutter package for creating beautiful Pie Charts with awesome animation. -version: 4.0.1 - -environment: - sdk: ">=2.2.2 <3.0.0" - -dependencies: - flutter: - sdk: flutter - -dev_dependencies: - flutter_test: - sdk: flutter - -# For information on the generic Dart part of this file, see the -# following page: https://www.dartlang.org/tools/pub/pubspec - -# The following section is specific to Flutter. -flutter: - -# To add assets to your package, add an assets section, like this: -# assets: -# - images/a_dot_burr.jpeg -# - images/a_dot_ham.jpeg -# -# For details regarding assets in packages, see -# https://flutter.io/assets-and-images/#from-packages -# -# An image asset can refer to one or more resolution-specific "variants", see -# https://flutter.io/assets-and-images/#resolution-aware. - -# To add custom fonts to your package, add a fonts section here, -# in this "flutter" section. Each entry in this list should have a -# "family" key with the font family name, and a "fonts" key with a -# list giving the asset and other descriptors for the font. For -# example: -# fonts: -# - family: Schyler -# fonts: -# - asset: fonts/Schyler-Regular.ttf -# - asset: fonts/Schyler-Italic.ttf -# style: italic -# - family: Trajan Pro -# fonts: -# - asset: fonts/TrajanPro.ttf -# - asset: fonts/TrajanPro_Bold.ttf -# weight: 700 -# -# For details regarding fonts in packages, see -# https://flutter.io/custom-fonts/#from-packages diff --git a/packages/edited_pie_chart/res/Screenshot1.png b/packages/edited_pie_chart/res/Screenshot1.png deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/edited_pie_chart/res/app.gif b/packages/edited_pie_chart/res/app.gif deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/edited_pie_chart/res/pub_logo.svg b/packages/edited_pie_chart/res/pub_logo.svg deleted file mode 100644 index a987367c..00000000 --- a/packages/edited_pie_chart/res/pub_logo.svg +++ /dev/null @@ -1 +0,0 @@ -pubpubv0.3.0 \ No newline at end of file diff --git a/packages/edited_pie_chart/res/s10.png b/packages/edited_pie_chart/res/s10.png deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/edited_pie_chart/res/s2.png b/packages/edited_pie_chart/res/s2.png deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/edited_pie_chart/res/s4.png b/packages/edited_pie_chart/res/s4.png deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/edited_pie_chart/res/s5.png b/packages/edited_pie_chart/res/s5.png deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/edited_pie_chart/res/s6.png b/packages/edited_pie_chart/res/s6.png deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/edited_pie_chart/res/s7.png b/packages/edited_pie_chart/res/s7.png deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/edited_pie_chart/res/s8.png b/packages/edited_pie_chart/res/s8.png deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/edited_pie_chart/res/s9.png b/packages/edited_pie_chart/res/s9.png deleted file mode 100644 index e69de29b..00000000 diff --git a/pubspec.lock b/pubspec.lock index 6a01886e..a28e034c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -909,13 +909,6 @@ packages: url: "https://pub.dev" source: hosted version: "5.1.0" - pie_chart: - dependency: "direct main" - description: - path: "packages/edited_pie_chart" - relative: true - source: path - version: "4.0.1" platform: dependency: transitive description: @@ -1169,6 +1162,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" + syncfusion_flutter_charts: + dependency: "direct main" + description: + name: syncfusion_flutter_charts + sha256: bdb7cc5814ceb187793cea587f4a5946afcffd96726b219cee79df8460f44b7b + url: "https://pub.dev" + source: hosted + version: "21.2.4" + syncfusion_flutter_core: + dependency: transitive + description: + name: syncfusion_flutter_core + sha256: "8db8f55c77f56968681447d3837c10f27a9e861e238a898fda116c7531def979" + url: "https://pub.dev" + source: hosted + version: "21.2.10" synchronized: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 4de0c3ed..0dda518e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -72,12 +72,11 @@ dependencies: lottie: ^2.3.0 shimmer: ^2.0.0 flutter_advanced_switch: ^3.0.1 - pie_chart: - path: packages/edited_pie_chart table_calendar: ^3.0.8 image_cropper: ^3.0.3 touchable: ^0.2.1 flutter_month_picker: ^0.0.2 + syncfusion_flutter_charts: ^21.2.3 dev_dependencies: flutter_test: