-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix float precision issue in sideTitles, #1473
- Loading branch information
Showing
7 changed files
with
196 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
PODS: | ||
- Flutter (1.0.0) | ||
- path_provider_foundation (0.0.1): | ||
- Flutter | ||
- FlutterMacOS | ||
- url_launcher_ios (0.0.1): | ||
- Flutter | ||
|
||
DEPENDENCIES: | ||
- Flutter (from `Flutter`) | ||
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) | ||
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) | ||
|
||
EXTERNAL SOURCES: | ||
Flutter: | ||
:path: Flutter | ||
path_provider_foundation: | ||
:path: ".symlinks/plugins/path_provider_foundation/darwin" | ||
url_launcher_ios: | ||
:path: ".symlinks/plugins/url_launcher_ios/ios" | ||
|
||
SPEC CHECKSUMS: | ||
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 | ||
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943 | ||
url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4 | ||
|
||
PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 | ||
|
||
COCOAPODS: 1.13.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,99 @@ | ||
import 'package:fl_chart_app/presentation/resources/app_resources.dart'; | ||
import 'package:fl_chart/fl_chart.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:google_fonts/google_fonts.dart'; | ||
|
||
import 'presentation/router/app_router.dart'; | ||
|
||
void main() { | ||
runApp(const MyApp()); | ||
runApp(MyApp()); | ||
} | ||
|
||
class MyApp extends StatelessWidget { | ||
const MyApp({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp.router( | ||
title: AppTexts.appName, | ||
theme: ThemeData( | ||
brightness: Brightness.dark, | ||
useMaterial3: true, | ||
textTheme: GoogleFonts.assistantTextTheme( | ||
Theme.of(context).textTheme.apply( | ||
bodyColor: AppColors.mainTextColor3, | ||
return const MaterialApp( | ||
home: HomePage(), | ||
); | ||
} | ||
} | ||
|
||
class HomePage extends StatelessWidget { | ||
const HomePage({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar(), | ||
body: _Body(), | ||
); | ||
} | ||
} | ||
|
||
class _Body extends StatelessWidget { | ||
_Body({super.key}); | ||
|
||
// final hourMinute = DateFormat('HH:mm:ss'); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Container( | ||
alignment: Alignment.center, | ||
height: 200, | ||
width: double.infinity, | ||
padding: const EdgeInsets.all(16), | ||
child: LineChart( | ||
LineChartData( | ||
minX: 1698797425, | ||
maxX: 1698797426, | ||
minY: 0, | ||
maxY: 10, | ||
titlesData: FlTitlesData( | ||
topTitles: const AxisTitles( | ||
sideTitles: SideTitles( | ||
showTitles: false, | ||
), | ||
), | ||
leftTitles: AxisTitles( | ||
sideTitles: SideTitles( | ||
showTitles: false, | ||
), | ||
), | ||
rightTitles: const AxisTitles( | ||
sideTitles: SideTitles( | ||
showTitles: false, | ||
), | ||
), | ||
bottomTitles: AxisTitles( | ||
sideTitles: SideTitles( | ||
showTitles: true, | ||
reservedSize: 40, | ||
getTitlesWidget: (double value, TitleMeta meta) { | ||
print('bottomTitles: $value'); | ||
final date = | ||
DateTime.fromMillisecondsSinceEpoch(value.toInt()); | ||
|
||
/// only show min & max title | ||
return value == meta.min || value == meta.max | ||
? SideTitleWidget( | ||
axisSide: meta.axisSide, | ||
space: 10, | ||
child: Text(date.toString()), | ||
) | ||
: const SizedBox(); | ||
}, | ||
), | ||
), | ||
), | ||
lineBarsData: [ | ||
LineChartBarData( | ||
spots: [ | ||
const FlSpot(1698797425, 0), | ||
const FlSpot(1698797426, 10), | ||
], | ||
), | ||
], | ||
), | ||
scaffoldBackgroundColor: AppColors.pageBackground, | ||
duration: Duration.zero, | ||
), | ||
routerConfig: appRouterConfig, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters