Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 34 additions & 20 deletions lib/metrics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class CategoryMetric {
this.hideOverview = false,
this.hideFlag = false,
this.max,
this.units,
});

String abbreviatedLocalizedName;
Expand All @@ -16,27 +17,38 @@ class CategoryMetric {
bool hideOverview;
bool hideFlag;
double? max;

String? units;
String path;

/// Optional override for completely custom formatting.
/// If null, default formatting is used (number + units).
String Function(dynamic)? valueToString;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were we going to make this add the units on by default?


String get abbreviatedNameWithUnits {
if (units == null || units!.trim().isEmpty) {
return abbreviatedLocalizedName;
}
return "$abbreviatedLocalizedName (${units!.trim()})";
}

String valueVizualizationBuilder(dynamic val) {
if (val == null) return "--";

// If a custom formatter is provided, use it
if (valueToString != null) {
if (val is num) {
return valueToString!(numToStringRounded(val));
} else if (val == null) {
return "--";
} else {
return valueToString!(val);
}
return valueToString!(val);
}

// Default behavior: number + units (if present)
if (val is num) {
return numToStringRounded(val);
final value = numToStringRounded(val);
return units != null ? "$value$units" : value;
}

return "--";
return val.toString();
}
}

Expand Down Expand Up @@ -103,13 +115,14 @@ final List<MetricCategoryData> metricCategories = [
CategoryMetric(
localizedName: "Scoring Rate (Fuel / Second)",
abbreviatedLocalizedName: "Scoring Rate",
valueToString: ((p0) => "$p0 bps"),
units: " bps",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this " bps" while feeding rate is "bps"?

path: "fuelPerSecond",
),
CategoryMetric(
localizedName: "Accuracy when shooting fuel",
abbreviatedLocalizedName: "Accuracy",
valueToString: ((p0) => "$p0%"),
units: "%",
max: 100,
path: "accuracy",
),
CategoryMetric(
Expand All @@ -122,13 +135,13 @@ final List<MetricCategoryData> metricCategories = [
CategoryMetric(
localizedName: "Time Spent Feeding",
abbreviatedLocalizedName: "Time Feeding",
valueToString: ((p0) => "${p0}s"),
units: "s",
path: "timeFeeding",
),
CategoryMetric(
localizedName: "Feeding Rate (Fuel / Second)",
abbreviatedLocalizedName: "Feeding Rate",
valueToString: ((p0) => "$p0 bps"),
units: " bps",
path: "feedingRate",
),
CategoryMetric(
Expand All @@ -141,58 +154,59 @@ final List<MetricCategoryData> metricCategories = [
CategoryMetric(
localizedName: "Driver Ability",
abbreviatedLocalizedName: "Driver Ability",
valueToString: ((p0) => "$p0/5"),
max: 5,
units: "1-5",
path: "driverAbility",
),
CategoryMetric(
localizedName: "Contact Defense Time",
abbreviatedLocalizedName: "Contact Defense Time",
valueToString: ((p0) => "${p0}s"),
units: "s",
path: "contactDefenseTime",
),
CategoryMetric(
localizedName: "Defense effectiveness",
abbreviatedLocalizedName: "Defense effectiveness",
valueToString: ((p0) => "$p0/5"),
units: "1-5",
max: 5,
path: "defenseEffectiveness",
),
CategoryMetric(
localizedName: "Camping Defense Time",
abbreviatedLocalizedName: "Camping Defense Time",
valueToString: ((p0) => "${p0}s"),
units: "s",
path: "campingDefenseTime",
),
CategoryMetric(
localizedName: "Total Defense Time (Camping + Contact)",
abbreviatedLocalizedName: "Total Defense Time",
valueToString: ((p0) => "${p0}s"),
units: "s",
path: "totalDefenseTime",
)
]),
MetricCategoryData("Climb", [
CategoryMetric(
localizedName: "Seconds left when starting to climb L1",
abbreviatedLocalizedName: "L1 Time",
valueToString: ((p0) => "${p0}s left"),
units: "s left",
path: "l1StartTime",
),
CategoryMetric(
localizedName: "Seconds left when starting to climb L2",
abbreviatedLocalizedName: "L2 Time",
valueToString: ((p0) => "${p0}s left"),
units: "s left",
path: "l2StartTime",
),
CategoryMetric(
localizedName: "Seconds left when starting to climb L3",
abbreviatedLocalizedName: "L3 Time",
valueToString: ((p0) => "${p0}s left"),
units: "s left",
path: "l3StartTime",
),
CategoryMetric(
localizedName: "Seconds left in auto when starting to climb in auto",
abbreviatedLocalizedName: "Auto Time",
valueToString: ((p0) => "${p0}s left"),
units: "s left",
path: "autoClimbStartTime",
),
]),
Expand Down
31 changes: 20 additions & 11 deletions lib/pages/team_lookup/team_lookup_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -276,19 +276,28 @@ class AnalysisOverview
bottomTitles: const AxisTitles(),
topTitles: const AxisTitles(),
leftTitles: AxisTitles(
axisNameWidget: Text(analysisFunction
.metric.abbreviatedLocalizedName),
axisNameWidget: Text(
analysisFunction.metric.abbreviatedNameWithUnits,
),
sideTitles: SideTitles(
showTitles: true,
getTitlesWidget: (value, meta) =>
SideTitleWidget(
meta: meta,
child: Text(
analysisFunction.metric
.valueVizualizationBuilder(value),
),
),
reservedSize: 50),
getTitlesWidget: (value, meta) {
final interval = meta.appliedInterval;
final isAligned =
value % interval > interval / 2;

if (value == meta.max &&
!isAligned &&
max == null) {
return const Text("");
}

return SideTitleWidget(
meta: meta,
child: Text(numToStringRounded(value)),
);
},
reservedSize: 40),
),
rightTitles: const AxisTitles(),
),
Expand Down