This repository has been archived by the owner on Aug 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Qizot
committed
Apr 14, 2020
1 parent
916a0f9
commit c397036
Showing
8 changed files
with
135 additions
and
46 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
frontend/coronavirus_visualizer/lib/src/ui/charts/daily_cases_timeline_chart.dart
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,61 @@ | ||
import 'package:charts_flutter/flutter.dart' as charts; | ||
import 'package:coronavirus_visualizer/src/models/timeline_item.dart'; | ||
import 'package:coronavirus_visualizer/src/ui/charts/total_timeline_details_dialog.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
|
||
class DailyCasesTimeline extends StatelessWidget { | ||
|
||
|
||
final List<charts.Series> seriesList; | ||
final bool animate; | ||
|
||
DailyCasesTimeline(List<TimelineItem> timelineItems, {this.animate}): seriesList = generateTimeSeries(timelineItems); | ||
|
||
static List<charts.Series<TimelineItem, DateTime>> generateTimeSeries(List<TimelineItem> timelineItems) { | ||
return [ | ||
charts.Series<TimelineItem, DateTime>( | ||
id: 'Daily Cases', | ||
colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, | ||
domainFn: (TimelineItem item, _) => item.date, | ||
measureFn: (TimelineItem item, _) => item.newCases, | ||
data: timelineItems, | ||
), | ||
]; | ||
} | ||
|
||
_onSelectionChanged(BuildContext context) { | ||
return (charts.SelectionModel<DateTime> model) { | ||
final selectedDatum = model.selectedDatum; | ||
|
||
if (selectedDatum.isNotEmpty) { | ||
final item = model.selectedDatum.first.datum as TimelineItem; | ||
showDialog(context: context, builder: (context) { | ||
return TotalTimelineDetailsDialog(timelineItem: item); | ||
}); | ||
|
||
} | ||
}; | ||
} | ||
|
||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return charts.TimeSeriesChart( | ||
seriesList, | ||
animate: animate, | ||
defaultRenderer: charts.LineRendererConfig(), | ||
customSeriesRenderers: [ | ||
charts.PointRendererConfig( | ||
customRendererId: 'customPoint') | ||
], | ||
selectionModels: [ | ||
charts.SelectionModelConfig( | ||
type: charts.SelectionModelType.info, | ||
changedListener: _onSelectionChanged(context), | ||
) | ||
], | ||
dateTimeFactory: const charts.LocalDateTimeFactory(), | ||
); | ||
} | ||
} |
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
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
32 changes: 32 additions & 0 deletions
32
frontend/coronavirus_visualizer/lib/src/ui/total_timeline/daily_cases_chart_card.dart
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,32 @@ | ||
|
||
import 'package:coronavirus_visualizer/src/models/timeline_item.dart'; | ||
import 'package:coronavirus_visualizer/src/ui/charts/daily_cases_timeline_chart.dart'; | ||
import 'package:coronavirus_visualizer/src/ui/total_timeline/utils.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
|
||
class DailyCasesChartCard extends StatelessWidget { | ||
final List<TimelineItem> timeline; | ||
|
||
DailyCasesChartCard({this.timeline}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Container( | ||
padding: EdgeInsets.all(8), | ||
margin: EdgeInsets.all(8), | ||
decoration: defaultGradientDecoration, | ||
child: Column( | ||
children: <Widget>[ | ||
SizedBox(height: 10), | ||
Text("New cases daily", style: TextStyle(fontFamily: "Baloo", fontSize: 30, color: Colors.white, fontWeight: FontWeight.w600)), | ||
SizedBox(height: 20), | ||
Container( | ||
height: 300, | ||
child: DailyCasesTimeline(timeline, animate: true) | ||
) | ||
], | ||
) | ||
); | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
frontend/coronavirus_visualizer/lib/src/ui/total_timeline/utils.dart
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,26 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
|
||
final defaultGradientDecoration = BoxDecoration( | ||
borderRadius: BorderRadius.circular(8), | ||
gradient: LinearGradient( | ||
colors: [ | ||
const Color(0xFF353535), // yellow sun | ||
const Color(0xFF111111), | ||
], | ||
begin: Alignment.topLeft, | ||
end: Alignment.bottomRight | ||
), | ||
boxShadow: [ | ||
BoxShadow( | ||
color: Colors.black, | ||
blurRadius: 20.0, | ||
spreadRadius: 5.0, | ||
offset: Offset( | ||
10, | ||
10 | ||
) | ||
) | ||
] | ||
); | ||
|