no chart
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:practice_engine/practice_engine.dart';
|
||||
|
||||
/// A chart widget that visualizes attempt progress over time.
|
||||
/// A chart widget that visualizes learning progress over time.
|
||||
/// Shows the percentage of questions that are still unknown (not yet learned).
|
||||
/// As you learn more questions, this percentage decreases.
|
||||
class AttemptsChart extends StatelessWidget {
|
||||
final List<AttemptHistoryEntry> attempts;
|
||||
final int maxDisplayItems;
|
||||
@@ -18,14 +20,14 @@ class AttemptsChart extends StatelessWidget {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
// Get recent attempts (most recent first, then reverse for display)
|
||||
final displayAttempts = attempts.reversed.take(maxDisplayItems).toList();
|
||||
// Get recent attempts (take most recent, then reverse so oldest is first for chronological display)
|
||||
final displayAttempts = attempts.reversed.take(maxDisplayItems).toList().reversed.toList();
|
||||
if (displayAttempts.isEmpty) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
// Find min and max values for scaling
|
||||
final percentages = displayAttempts.map((e) => e.percentageCorrect).toList();
|
||||
// Find min and max values for scaling (using unknown percentage)
|
||||
final percentages = displayAttempts.map((e) => e.unknownPercentage).toList();
|
||||
final minValue = percentages.reduce((a, b) => a < b ? a : b);
|
||||
final maxValue = percentages.reduce((a, b) => a > b ? a : b);
|
||||
final range = (maxValue - minValue).clamp(10.0, 100.0); // Ensure minimum range
|
||||
@@ -148,7 +150,7 @@ class _AttemptsChartPainter extends CustomPainter {
|
||||
final points = <Offset>[];
|
||||
|
||||
for (int i = 0; i < attempts.length; i++) {
|
||||
final percentage = attempts[i].percentageCorrect;
|
||||
final percentage = attempts[i].unknownPercentage;
|
||||
final normalizedValue = chartRange > 0
|
||||
? ((percentage - chartMin) / chartRange).clamp(0.0, 1.0)
|
||||
: 0.5; // If all values are the same, center vertically
|
||||
@@ -201,7 +203,7 @@ class _AttemptsChartPainter extends CustomPainter {
|
||||
}
|
||||
|
||||
// Draw average line (dashed)
|
||||
final avgPercentage = attempts.map((e) => e.percentageCorrect).reduce((a, b) => a + b) / attempts.length;
|
||||
final avgPercentage = attempts.map((e) => e.unknownPercentage).reduce((a, b) => a + b) / attempts.length;
|
||||
final avgNormalized = ((avgPercentage - chartMin) / chartRange).clamp(0.0, 1.0);
|
||||
final avgY = padding + chartHeight - (avgNormalized * chartHeight);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user