Skip to content

Commit

Permalink
fix(graphs): support fl_chart@0.55.1
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
JagandeepBrar committed Aug 30, 2022
1 parent 96b2067 commit b812c7b
Show file tree
Hide file tree
Showing 9 changed files with 264 additions and 247 deletions.
18 changes: 9 additions & 9 deletions android/Gemfile.lock
Expand Up @@ -3,13 +3,13 @@ GEM
specs:
CFPropertyList (3.0.5)
rexml
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.0)
artifactory (3.0.15)
atomos (0.1.3)
aws-eventstream (1.2.0)
aws-partitions (1.618.0)
aws-sdk-core (3.132.0)
aws-partitions (1.623.0)
aws-sdk-core (3.136.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.525.0)
aws-sigv4 (~> 1.1)
Expand Down Expand Up @@ -37,7 +37,7 @@ GEM
dotenv (2.8.1)
emoji_regex (3.2.3)
excon (0.92.4)
faraday (1.10.1)
faraday (1.10.2)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
Expand Down Expand Up @@ -66,7 +66,7 @@ GEM
faraday_middleware (1.2.0)
faraday (~> 1.0)
fastimage (2.2.6)
fastlane (2.209.0)
fastlane (2.209.1)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
Expand Down Expand Up @@ -129,7 +129,7 @@ GEM
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
google-cloud-errors (1.2.0)
google-cloud-storage (1.38.0)
google-cloud-storage (1.39.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-iamcredentials_v1 (~> 0.1)
Expand All @@ -150,7 +150,7 @@ GEM
httpclient (2.8.3)
jmespath (1.6.1)
json (2.6.2)
jwt (2.4.1)
jwt (2.5.0)
memoist (0.16.2)
mini_magick (4.11.0)
mini_mime (1.1.2)
Expand All @@ -161,7 +161,7 @@ GEM
optparse (0.1.1)
os (1.1.4)
plist (3.6.0)
public_suffix (4.0.7)
public_suffix (5.0.0)
rake (13.0.6)
representable (3.2.0)
declarative (< 0.1.0)
Expand Down
18 changes: 9 additions & 9 deletions ios/Gemfile.lock
Expand Up @@ -9,16 +9,16 @@ GEM
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
artifactory (3.0.15)
atomos (0.1.3)
aws-eventstream (1.2.0)
aws-partitions (1.618.0)
aws-sdk-core (3.132.0)
aws-partitions (1.623.0)
aws-sdk-core (3.136.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.525.0)
aws-sigv4 (~> 1.1)
Expand Down Expand Up @@ -87,7 +87,7 @@ GEM
ethon (0.15.0)
ffi (>= 1.15.0)
excon (0.92.4)
faraday (1.10.1)
faraday (1.10.2)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
Expand Down Expand Up @@ -116,7 +116,7 @@ GEM
faraday_middleware (1.2.0)
faraday (~> 1.0)
fastimage (2.2.6)
fastlane (2.209.0)
fastlane (2.209.1)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
Expand Down Expand Up @@ -182,7 +182,7 @@ GEM
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
google-cloud-errors (1.2.0)
google-cloud-storage (1.38.0)
google-cloud-storage (1.39.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-iamcredentials_v1 (~> 0.1)
Expand All @@ -205,11 +205,11 @@ GEM
concurrent-ruby (~> 1.0)
jmespath (1.6.1)
json (2.6.2)
jwt (2.4.1)
jwt (2.5.0)
memoist (0.16.2)
mini_magick (4.11.0)
mini_mime (1.1.2)
minitest (5.16.2)
minitest (5.16.3)
molinillo (0.8.0)
multi_json (1.15.0)
multipart-post (2.0.0)
Expand Down
63 changes: 38 additions & 25 deletions lib/modules/tautulli/core/graphs/graph.dart
Expand Up @@ -21,33 +21,46 @@ class TautulliGraphHelper {
TautulliGraphData data, {
int maxTitleLength = DEFAULT_MAX_TITLE_LENGTH,
bool titleOverFlowShowEllipsis = true,
}) =>
FlTitlesData(
leftTitles: SideTitles(showTitles: false),
rightTitles: SideTitles(showTitles: false),
topTitles: SideTitles(showTitles: false),
bottomTitles: SideTitles(
}) {
String _getTitle(double value) {
return data.categories![value.truncate()]!.length > maxTitleLength + 1
? [
data.categories![value.truncate()]!
.substring(
0,
min(maxTitleLength,
data.categories![value.truncate()]!.length))
.toUpperCase(),
if (titleOverFlowShowEllipsis) LunaUI.TEXT_ELLIPSIS,
].join()
: data.categories![value.truncate()]!.toUpperCase();
}

return FlTitlesData(
leftTitles: AxisTitles(sideTitles: SideTitles(showTitles: false)),
rightTitles: AxisTitles(sideTitles: SideTitles(showTitles: false)),
topTitles: AxisTitles(sideTitles: SideTitles(showTitles: false)),
bottomTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
margin: 8.0,
reservedSize: 8.0,
getTitles: (value) =>
data.categories![value.truncate()]!.length > maxTitleLength + 1
? [
data.categories![value.truncate()]!
.substring(
0,
min(maxTitleLength,
data.categories![value.truncate()]!.length))
.toUpperCase(),
if (titleOverFlowShowEllipsis) LunaUI.TEXT_ELLIPSIS,
].join()
: data.categories![value.truncate()]!.toUpperCase(),
getTextStyles: (_, __) => const TextStyle(
color: LunaColours.grey,
fontSize: LunaUI.FONT_SIZE_GRAPH_LEGEND,
),
reservedSize:
LunaUI.FONT_SIZE_GRAPH_LEGEND + LunaUI.DEFAULT_MARGIN_SIZE,
getTitlesWidget: (value, meta) {
return Padding(
padding: const EdgeInsets.only(top: LunaUI.DEFAULT_MARGIN_SIZE),
child: Text(
_getTitle(value),
style: const TextStyle(
color: LunaColours.grey,
fontSize: LunaUI.FONT_SIZE_GRAPH_LEGEND,
),
),
);
},
),
);
),
);
}

Widget createLegend(List<TautulliSeriesData> data) {
return SizedBox(
Expand Down
98 changes: 52 additions & 46 deletions lib/modules/tautulli/core/graphs/line_graph.dart
Expand Up @@ -8,61 +8,67 @@ class TautulliLineGraphHelper {
TautulliLineGraphHelper._();

static FlTitlesData titlesData(TautulliGraphData data) {
String _getTitles(double value) {
String _getTitle(double value) {
DateTime? _dt = DateTime.tryParse(data.categories![value.truncate()]!);
return _dt != null ? DateFormat('dd').format(_dt).toString() : '??';
}

return FlTitlesData(
leftTitles: SideTitles(showTitles: false),
rightTitles: SideTitles(showTitles: false),
topTitles: SideTitles(showTitles: false),
bottomTitles: SideTitles(
showTitles: true,
margin: 8.0,
reservedSize: 8.0,
getTitles: _getTitles,
getTextStyles: (_, __) => const TextStyle(
color: LunaColours.grey,
fontSize: LunaUI.FONT_SIZE_GRAPH_LEGEND,
leftTitles: AxisTitles(sideTitles: SideTitles(showTitles: false)),
rightTitles: AxisTitles(sideTitles: SideTitles(showTitles: false)),
topTitles: AxisTitles(sideTitles: SideTitles(showTitles: false)),
bottomTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
reservedSize:
LunaUI.FONT_SIZE_GRAPH_LEGEND + LunaUI.DEFAULT_MARGIN_SIZE,
getTitlesWidget: (value, meta) => Padding(
padding: const EdgeInsets.only(top: LunaUI.DEFAULT_MARGIN_SIZE),
child: Text(
_getTitle(value),
style: const TextStyle(
color: LunaColours.grey,
fontSize: LunaUI.FONT_SIZE_GRAPH_LEGEND,
),
),
),
),
),
);
}

static List<LineChartBarData> lineBarsData(TautulliGraphData data) =>
List<LineChartBarData>.generate(
data.series!.length,
(sIndex) => LineChartBarData(
isCurved: true,
isStrokeCapRound: true,
barWidth: 3.0,
colors: [LunaColours().byGraphLayer(sIndex)],
spots: List<FlSpot>.generate(
data.series![sIndex].data!.length,
(dIndex) => FlSpot(dIndex.toDouble(),
data.series![sIndex].data![dIndex]!.toDouble()),
),
belowBarData: BarAreaData(
show: true,
colors: [
LunaColours()
.byGraphLayer(sIndex)
.withOpacity(LunaUI.OPACITY_SPLASH)
],
),
dotData: FlDotData(
show: true,
getDotPainter: (FlSpot spot, double xPercentage,
LineChartBarData bar, int index) =>
FlDotCirclePainter(
radius: 2.50,
strokeColor: bar.colors[0],
color: bar.colors[0],
),
static List<LineChartBarData> lineBarsData(TautulliGraphData data) {
return List<LineChartBarData>.generate(
data.series!.length,
(sIndex) => LineChartBarData(
isCurved: true,
isStrokeCapRound: true,
barWidth: 3.0,
color: LunaColours().byGraphLayer(sIndex),
spots: List<FlSpot>.generate(
data.series![sIndex].data!.length,
(dIndex) => FlSpot(dIndex.toDouble(),
data.series![sIndex].data![dIndex]!.toDouble()),
),
belowBarData: BarAreaData(
show: true,
color: LunaColours()
.byGraphLayer(sIndex)
.withOpacity(LunaUI.OPACITY_SPLASH),
),
dotData: FlDotData(
show: true,
getDotPainter: (FlSpot spot, double xPercentage, LineChartBarData bar,
int index) =>
FlDotCirclePainter(
radius: 2.50,
strokeColor: bar.color,
color: bar.color,
),
),
);
),
);
}

static LineTouchData lineTouchData(
BuildContext context,
Expand Down Expand Up @@ -107,16 +113,16 @@ class TautulliLineGraphHelper {
(index) => TouchedSpotIndicatorData(
FlLine(
strokeWidth: 3.0,
color: bar.colors[0].withOpacity(LunaUI.OPACITY_DISABLED),
color: bar.color!.withOpacity(LunaUI.OPACITY_DISABLED),
),
FlDotData(
show: true,
getDotPainter: (FlSpot spot, double xPercentage,
LineChartBarData bar, int index) =>
FlDotCirclePainter(
radius: 5.0,
strokeColor: bar.colors[0],
color: bar.colors[0],
strokeColor: bar.color,
color: bar.color,
),
),
),
Expand Down
18 changes: 9 additions & 9 deletions macos/Gemfile.lock
Expand Up @@ -9,16 +9,16 @@ GEM
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
artifactory (3.0.15)
atomos (0.1.3)
aws-eventstream (1.2.0)
aws-partitions (1.618.0)
aws-sdk-core (3.132.0)
aws-partitions (1.623.0)
aws-sdk-core (3.136.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.525.0)
aws-sigv4 (~> 1.1)
Expand Down Expand Up @@ -87,7 +87,7 @@ GEM
ethon (0.15.0)
ffi (>= 1.15.0)
excon (0.92.4)
faraday (1.10.1)
faraday (1.10.2)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
Expand Down Expand Up @@ -116,7 +116,7 @@ GEM
faraday_middleware (1.2.0)
faraday (~> 1.0)
fastimage (2.2.6)
fastlane (2.209.0)
fastlane (2.209.1)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
Expand Down Expand Up @@ -182,7 +182,7 @@ GEM
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
google-cloud-errors (1.2.0)
google-cloud-storage (1.38.0)
google-cloud-storage (1.39.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-iamcredentials_v1 (~> 0.1)
Expand All @@ -205,11 +205,11 @@ GEM
concurrent-ruby (~> 1.0)
jmespath (1.6.1)
json (2.6.2)
jwt (2.4.1)
jwt (2.5.0)
memoist (0.16.2)
mini_magick (4.11.0)
mini_mime (1.1.2)
minitest (5.16.2)
minitest (5.16.3)
molinillo (0.8.0)
multi_json (1.15.0)
multipart-post (2.0.0)
Expand Down

0 comments on commit b812c7b

Please sign in to comment.