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

Merged
merged 27 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
71dbf1b
Add error indicator data classes in our axis-based charts
imaNNeo Jan 7, 2025
34630a2
Test
imaNNeo Jan 7, 2025
dd5e703
Implement simple drawing error functionality (tested in line_chart_sa…
imaNNeo Jan 8, 2025
ff4d684
Fix non-symmetric error indicator draw functionality
imaNNeo Jan 8, 2025
c135ce7
Move the errorIndicatorData property to the line objects (instead of …
imaNNeo Jan 9, 2025
addafb8
Simplify the error indicator painter
imaNNeo Jan 9, 2025
9da7d68
Set the show = true for error indicator lines
imaNNeo Jan 9, 2025
ca5b1bd
Add crossAlignment property to be able to align the error indicator line
imaNNeo Jan 9, 2025
daf6257
Update line_chart_sample8 colors
imaNNeo Jan 9, 2025
fcda4ee
Add line_chart_sample13 to demonestrate the amsterdam weather with th…
imaNNeo Jan 10, 2025
7ccc1ca
Add error text in the FlSimpleErrorPainter
imaNNeo Jan 10, 2025
867d89b
Remove dead code from utils.dart
imaNNeo Jan 10, 2025
5a0fbfe
Show formatted number in the error indicator painter
imaNNeo Jan 10, 2025
b4bf1bd
Simplify line_chart_painter.dart
imaNNeo Jan 10, 2025
8c9596a
Add generic type for the error painter to be able to support other ch…
imaNNeo Jan 10, 2025
f652121
Implement error indicator in bar chart. (sample 8)
imaNNeo Jan 10, 2025
66b5800
Add error indicator functionality in the Scatter Chart
imaNNeo Jan 11, 2025
5b160bd
Update the dart documentation
imaNNeo Jan 13, 2025
3af5175
Update the markdown documentation
imaNNeo Jan 13, 2025
327f325
Fix formatting issue
imaNNeo Jan 13, 2025
8ad87a1
Update the code-generation deprecated command
imaNNeo Jan 15, 2025
ec2ea3d
Re-run code-gen to re-generate all the .mock files
imaNNeo Jan 15, 2025
c1a4e29
Add some unit-tests in line_chart_painter_test.dart
imaNNeo Jan 15, 2025
553f0a1
Update the `make format` and `make checkFormat` commands to exclude t…
imaNNeo Jan 15, 2025
8e56e73
Add errorIndicatorData in our mockData (to check the equality)
imaNNeo Jan 15, 2025
ff78b83
Add some unit-tests for the FlSpotErrorRangePainter
imaNNeo Jan 16, 2025
d090994
Update the CHANGELOG.md
imaNNeo Jan 16, 2025
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ example/android/app/.settings/org.eclipse.buildship.core.prefs
example/macos/Flutter/ephemeral/
coverage/
.fvm/

# Files generated by dart tools
.dart_tool
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## newVersion
* **FEATURE** (by @imaNNeo) Add error range feature in our axis-based charts. You can set `xError` and `yError` in the [FlSpot](https://github.com/imaNNeo/fl_chart/blob/main/repo_files/documentations/base_chart.md#flspot) or `toYErrorRange` in [BarChartRodData](https://github.com/imaNNeo/fl_chart/blob/main/repo_files/documentations/bar_chart.md#barchartroddata). Also we have `errorIndicatorData` property in our [LineChartData](https://github.com/imaNNeo/fl_chart/blob/main/repo_files/documentations/line_chart.md#linechartdata), [BarChartData](https://github.com/imaNNeo/fl_chart/blob/main/repo_files/documentations/bar_chart.md#barchartdata) and [ScatterChartData](https://github.com/imaNNeo/fl_chart/blob/main/repo_files/documentations/scatter_chart.md#scatterchartdata) that is responsible to render the error bars. You can take a look at the [LineChartSample 13](https://github.com/imaNNeo/fl_chart/blob/main/example/lib/presentation/samples/line/line_chart_sample13.dart) and [BarChartSample 8](https://github.com/imaNNeo/fl_chart/blob/main/example/lib/presentation/samples/bar/bar_chart_sample8.dart) in our [sample app](https://app.flchart.dev), #1483

## 0.70.1
* **FEATURE** (by @Peetee06) Add `panEnabled` and `scaleEnabled` properties in the TransformationController, #1818
* **FEATURE** (by @mitulagr2) Add `renderPriority` feature in our [ScatterSpot](https://github.com/imaNNeo/fl_chart/blob/main/repo_files/documentations/scatter_chart.md#scatterspot), #1545
Expand Down
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
ifeq ($(OS),Windows_NT)
FIND_CMD=dir /S /B lib\*.dart test\*.dart | findstr /V .mocks.dart
else
FIND_CMD=find lib test -name '*.dart' -not -name '*.mocks.dart'
endif

analyze:
flutter analyze

checkFormat:
dart format -o none --set-exit-if-changed .
dart format -o none --set-exit-if-changed $$( $(FIND_CMD) )

checkstyle:
make analyze && make checkFormat

format:
dart format .
dart format $$( $(FIND_CMD) )

runTests:
flutter test
Expand All @@ -27,7 +33,7 @@ sure:

# To create generated files (for example mock files in unit_tests)
codeGen:
flutter pub run build_runner build --delete-conflicting-outputs
dart run build_runner build --delete-conflicting-outputs

showTestCoverage:
flutter test --coverage
Expand Down
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