From bef625a934a41de0c5bcbe134510a3792ceefffc Mon Sep 17 00:00:00 2001 From: Inex Code Date: Tue, 5 Apr 2022 18:50:47 +0300 Subject: [PATCH] Update breaking fl_chart dependency --- lib/ui/pages/server_details/cpu_chart.dart | 59 +++++++++------ .../pages/server_details/network_charts.dart | 71 ++++++++++++------- pubspec.lock | 2 +- pubspec.yaml | 2 +- 4 files changed, 83 insertions(+), 51 deletions(-) diff --git a/lib/ui/pages/server_details/cpu_chart.dart b/lib/ui/pages/server_details/cpu_chart.dart index a42f38f3..fd131e61 100644 --- a/lib/ui/pages/server_details/cpu_chart.dart +++ b/lib/ui/pages/server_details/cpu_chart.dart @@ -35,9 +35,7 @@ class CpuChart extends StatelessWidget { spots: getSpots(), isCurved: true, barWidth: 1, - colors: [ - Colors.red, - ], + color: Colors.red, dotData: FlDotData( show: false, ), @@ -47,28 +45,45 @@ class CpuChart extends StatelessWidget { maxY: 100, minX: data.length - 200, titlesData: FlTitlesData( - topTitles: SideTitles(showTitles: false), - bottomTitles: SideTitles( + topTitles: AxisTitles(sideTitles: SideTitles(showTitles: false)), + bottomTitles: AxisTitles( + sideTitles: SideTitles( interval: 20, - rotateAngle: 90.0, - showTitles: true, - getTextStyles: (_, __) => const TextStyle( - fontSize: 10, - color: Colors.purple, - fontWeight: FontWeight.bold, + reservedSize: 50, + getTitlesWidget: (value, titleMeta) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: RotatedBox( + child: Text(bottomTitle(value.toInt()), + style: TextStyle( + fontSize: 10, + color: Colors.purple, + fontWeight: FontWeight.bold, + )), + quarterTurns: 1, ), - getTitles: (value) { - return bottomTitle(value.toInt()); - }), - leftTitles: SideTitles( - getTextStyles: (_, __) => progressTextStyleLight.copyWith( - color: Theme.of(context).brightness == Brightness.dark - ? BrandColors.gray4 - : null, + ); + }, + showTitles: true, + ), + ), + leftTitles: AxisTitles( + sideTitles: SideTitles( + getTitlesWidget: (value, titleMeta) { + return Padding( + padding: EdgeInsets.only(right: 15), + child: Text( + value.toInt().toString(), + style: progressTextStyleLight.copyWith( + color: Theme.of(context).brightness == Brightness.dark + ? BrandColors.gray4 + : null, + ), + )); + }, + interval: 25, + showTitles: false, ), - margin: 15, - interval: 25, - showTitles: true, ), ), gridData: FlGridData(show: true), diff --git a/lib/ui/pages/server_details/network_charts.dart b/lib/ui/pages/server_details/network_charts.dart index 60f54663..8827eb9f 100644 --- a/lib/ui/pages/server_details/network_charts.dart +++ b/lib/ui/pages/server_details/network_charts.dart @@ -44,7 +44,7 @@ class NetworkChart extends StatelessWidget { spots: getSpots(listData[0]), isCurved: true, barWidth: 1, - colors: [Colors.red], + color: Colors.red, dotData: FlDotData( show: false, ), @@ -53,7 +53,7 @@ class NetworkChart extends StatelessWidget { spots: getSpots(listData[1]), isCurved: true, barWidth: 1, - colors: [Colors.green], + color: Colors.green, dotData: FlDotData( show: false, ), @@ -67,34 +67,51 @@ class NetworkChart extends StatelessWidget { 1.2, minX: listData[0].length - 200, titlesData: FlTitlesData( - topTitles: SideTitles(showTitles: false), - bottomTitles: SideTitles( + topTitles: AxisTitles(sideTitles: SideTitles(showTitles: false)), + bottomTitles: AxisTitles( + sideTitles: SideTitles( interval: 20, - rotateAngle: 90.0, - showTitles: true, - getTextStyles: (_, __) => const TextStyle( - fontSize: 10, - color: Colors.purple, - fontWeight: FontWeight.bold, + reservedSize: 50, + getTitlesWidget: (value, titleMeta) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: RotatedBox( + child: Text(bottomTitle(value.toInt()), + style: TextStyle( + fontSize: 10, + color: Colors.purple, + fontWeight: FontWeight.bold, + )), + quarterTurns: 1, ), - getTitles: (value) { - return bottomTitle(value.toInt()); - }), - leftTitles: SideTitles( - reservedSize: 50, - margin: 5, - interval: [ - ...listData[0].map((e) => e.value), - ...listData[1].map((e) => e.value) - ].reduce(max) * - 2 / - 10, - getTextStyles: (_, __) => progressTextStyleLight.copyWith( - color: Theme.of(context).brightness == Brightness.dark - ? BrandColors.gray4 - : null, + ); + }, + showTitles: true, + ), + ), + leftTitles: AxisTitles( + sideTitles: SideTitles( + reservedSize: 50, + getTitlesWidget: (value, titleMeta) { + return Padding( + padding: EdgeInsets.only(right: 5), + child: Text( + value.toInt().toString(), + style: progressTextStyleLight.copyWith( + color: Theme.of(context).brightness == Brightness.dark + ? BrandColors.gray4 + : null, + ), + )); + }, + interval: [ + ...listData[0].map((e) => e.value), + ...listData[1].map((e) => e.value) + ].reduce(max) * + 2 / + 10, + showTitles: false, ), - showTitles: true, ), ), gridData: FlGridData(show: true), diff --git a/pubspec.lock b/pubspec.lock index 24f40613..681a805a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -301,7 +301,7 @@ packages: name: fl_chart url: "https://pub.dartlang.org" source: hosted - version: "0.45.0" + version: "0.50.1" flutter: dependency: "direct main" description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index 8dd22169..fcdd081f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ dependencies: easy_localization: ^3.0.0 either_option: ^2.0.1-dev.1 equatable: ^2.0.3 - fl_chart: ^0.45.0 + fl_chart: ^0.50.1 flutter: sdk: flutter flutter_bloc: ^8.0.1