Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Feature/error indicator #1842

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
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
367 changes: 367 additions & 0 deletions example/assets/data/amsterdam_2024_weather.csv

Large diffs are not rendered by default.

37 changes: 33 additions & 4 deletions example/lib/presentation/samples/bar/bar_chart_sample8.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,14 @@ class BarChartSample1State extends State<BarChartSample8> {
BarChartGroupData makeGroupData(
int x,
double y,
FlErrorRange errorRange,
) {
return BarChartGroupData(
x: x,
barRods: [
BarChartRodData(
toY: y,
toYErrorRange: errorRange,
color: x >= 4 ? Colors.transparent : widget.barColor,
borderRadius: BorderRadius.zero,
borderDashArray: x >= 4 ? [4, 4] : null,
Expand Down Expand Up @@ -134,12 +136,39 @@ class BarChartSample1State extends State<BarChartSample8> {
),
barGroups: List.generate(
7,
(i) => makeGroupData(
i,
Random().nextInt(290).toDouble() + 10,
),
(i) {
final y = Random().nextInt(290).toDouble() + 10;
final lowerBy = y < 50
? Random().nextDouble() * 10
: Random().nextDouble() * 30 + 5;
final upperBy = y > 290
? Random().nextDouble() * 10
: Random().nextDouble() * 30 + 5;
return makeGroupData(
i,
y,
FlErrorRange(
lowerBy: lowerBy,
upperBy: upperBy,
),
);
},
),
gridData: const FlGridData(show: false),
errorIndicatorData: FlErrorIndicatorData(
painter: _errorPainter,
),
);
}

FlSpotErrorRangePainter _errorPainter(
BarChartSpotErrorRangeCallbackInput input,
) =>
FlSimpleErrorPainter(
lineWidth: 2.0,
capLength: 14,
lineColor: input.groupIndex < 4
? AppColors.contentColorOrange
: AppColors.primary.withValues(alpha: 0.5),
);
}
2 changes: 2 additions & 0 deletions example/lib/presentation/samples/chart_samples.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'line/line_chart_sample1.dart';
import 'line/line_chart_sample10.dart';
import 'line/line_chart_sample11.dart';
import 'line/line_chart_sample12.dart';
import 'line/line_chart_sample13.dart';
import 'line/line_chart_sample2.dart';
import 'line/line_chart_sample3.dart';
import 'line/line_chart_sample4.dart';
Expand Down Expand Up @@ -43,6 +44,7 @@ class ChartSamples {
LineChartSample(10, (context) => const LineChartSample10()),
LineChartSample(11, (context) => const LineChartSample11()),
LineChartSample(12, (context) => const LineChartSample12()),
LineChartSample(13, (context) => const LineChartSample13()),
],
ChartType.bar: [
BarChartSample(1, (context) => BarChartSample1()),
Expand Down
Loading
Loading