|
|
|
@ -19,21 +19,23 @@ import 'package:github_dataviz/mathutils.dart';
|
|
|
|
|
import 'package:github_dataviz/timeline.dart';
|
|
|
|
|
|
|
|
|
|
class MainLayout extends StatefulWidget {
|
|
|
|
|
const MainLayout({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_MainLayoutState createState() => _MainLayoutState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _MainLayoutState extends State<MainLayout> with TickerProviderStateMixin {
|
|
|
|
|
AnimationController _animation;
|
|
|
|
|
List<UserContribution> contributions;
|
|
|
|
|
List<StatForWeek> starsByWeek;
|
|
|
|
|
List<StatForWeek> forksByWeek;
|
|
|
|
|
List<StatForWeek> pushesByWeek;
|
|
|
|
|
List<StatForWeek> issueCommentsByWeek;
|
|
|
|
|
List<StatForWeek> pullRequestActivityByWeek;
|
|
|
|
|
List<WeekLabel> weekLabels;
|
|
|
|
|
|
|
|
|
|
static final double earlyInterpolatorFraction = 0.8;
|
|
|
|
|
AnimationController? _animation;
|
|
|
|
|
List<UserContribution>? contributions;
|
|
|
|
|
List<StatForWeek>? starsByWeek;
|
|
|
|
|
List<StatForWeek>? forksByWeek;
|
|
|
|
|
List<StatForWeek>? pushesByWeek;
|
|
|
|
|
List<StatForWeek>? issueCommentsByWeek;
|
|
|
|
|
List<StatForWeek>? pullRequestActivityByWeek;
|
|
|
|
|
late List<WeekLabel> weekLabels;
|
|
|
|
|
|
|
|
|
|
static const double earlyInterpolatorFraction = 0.8;
|
|
|
|
|
static final EarlyInterpolator interpolator =
|
|
|
|
|
EarlyInterpolator(earlyInterpolatorFraction);
|
|
|
|
|
double animationValue = 1.0;
|
|
|
|
@ -47,14 +49,14 @@ class _MainLayoutState extends State<MainLayout> with TickerProviderStateMixin {
|
|
|
|
|
createAnimation(0);
|
|
|
|
|
|
|
|
|
|
weekLabels = <WeekLabel>[];
|
|
|
|
|
weekLabels.add(WeekLabel.forDate(DateTime(2019, 2, 26), "v1.2"));
|
|
|
|
|
weekLabels.add(WeekLabel.forDate(DateTime(2018, 12, 4), "v1.0"));
|
|
|
|
|
weekLabels.add(WeekLabel.forDate(DateTime(2019, 2, 26), 'v1.2'));
|
|
|
|
|
weekLabels.add(WeekLabel.forDate(DateTime(2018, 12, 4), 'v1.0'));
|
|
|
|
|
// weekLabels.add(WeekLabel.forDate(new DateTime(2018, 9, 19), "Preview 2"));
|
|
|
|
|
weekLabels.add(WeekLabel.forDate(DateTime(2018, 6, 21), "Preview 1"));
|
|
|
|
|
weekLabels.add(WeekLabel.forDate(DateTime(2018, 6, 21), 'Preview 1'));
|
|
|
|
|
// weekLabels.add(WeekLabel.forDate(new DateTime(2018, 5, 7), "Beta 3"));
|
|
|
|
|
weekLabels.add(WeekLabel.forDate(DateTime(2018, 2, 27), "Beta 1"));
|
|
|
|
|
weekLabels.add(WeekLabel.forDate(DateTime(2017, 5, 1), "Alpha"));
|
|
|
|
|
weekLabels.add(WeekLabel(48, "Repo Made Public"));
|
|
|
|
|
weekLabels.add(WeekLabel.forDate(DateTime(2018, 2, 27), 'Beta 1'));
|
|
|
|
|
weekLabels.add(WeekLabel.forDate(DateTime(2017, 5, 1), 'Alpha'));
|
|
|
|
|
weekLabels.add(WeekLabel(48, 'Repo Made Public'));
|
|
|
|
|
|
|
|
|
|
loadGitHubData();
|
|
|
|
|
}
|
|
|
|
@ -66,10 +68,10 @@ class _MainLayoutState extends State<MainLayout> with TickerProviderStateMixin {
|
|
|
|
|
duration: const Duration(milliseconds: 14400),
|
|
|
|
|
vsync: this,
|
|
|
|
|
)..repeat();
|
|
|
|
|
_animation.addListener(() {
|
|
|
|
|
_animation!.addListener(() {
|
|
|
|
|
setState(() {
|
|
|
|
|
if (!timelineOverride) {
|
|
|
|
|
animationValue = _animation.value;
|
|
|
|
|
animationValue = _animation!.value;
|
|
|
|
|
interpolatedAnimationValue = interpolator.get(animationValue);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
@ -82,7 +84,7 @@ class _MainLayoutState extends State<MainLayout> with TickerProviderStateMixin {
|
|
|
|
|
List<DataSeries> dataToPlot = [];
|
|
|
|
|
if (contributions != null) {
|
|
|
|
|
List<int> series = [];
|
|
|
|
|
for (UserContribution userContrib in contributions) {
|
|
|
|
|
for (UserContribution userContrib in contributions!) {
|
|
|
|
|
for (int i = 0; i < userContrib.contributions.length; i++) {
|
|
|
|
|
ContributionData data = userContrib.contributions[i];
|
|
|
|
|
if (series.length > i) {
|
|
|
|
@ -92,32 +94,32 @@ class _MainLayoutState extends State<MainLayout> with TickerProviderStateMixin {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dataToPlot.add(DataSeries("Added Lines", series));
|
|
|
|
|
dataToPlot.add(DataSeries('Added Lines', series));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (starsByWeek != null) {
|
|
|
|
|
dataToPlot
|
|
|
|
|
.add(DataSeries("Stars", starsByWeek.map((e) => e.stat).toList()));
|
|
|
|
|
.add(DataSeries('Stars', starsByWeek!.map((e) => e.stat).toList()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (forksByWeek != null) {
|
|
|
|
|
dataToPlot
|
|
|
|
|
.add(DataSeries("Forks", forksByWeek.map((e) => e.stat).toList()));
|
|
|
|
|
.add(DataSeries('Forks', forksByWeek!.map((e) => e.stat).toList()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pushesByWeek != null) {
|
|
|
|
|
dataToPlot
|
|
|
|
|
.add(DataSeries("Pushes", pushesByWeek.map((e) => e.stat).toList()));
|
|
|
|
|
.add(DataSeries('Pushes', pushesByWeek!.map((e) => e.stat).toList()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (issueCommentsByWeek != null) {
|
|
|
|
|
dataToPlot.add(DataSeries(
|
|
|
|
|
"Issue Comments", issueCommentsByWeek.map((e) => e.stat).toList()));
|
|
|
|
|
'Issue Comments', issueCommentsByWeek!.map((e) => e.stat).toList()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pullRequestActivityByWeek != null) {
|
|
|
|
|
dataToPlot.add(DataSeries("Pull Request Activity",
|
|
|
|
|
pullRequestActivityByWeek.map((e) => e.stat).toList()));
|
|
|
|
|
dataToPlot.add(DataSeries('Pull Request Activity',
|
|
|
|
|
pullRequestActivityByWeek!.map((e) => e.stat).toList()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LayeredChart layeredChart =
|
|
|
|
@ -126,15 +128,13 @@ class _MainLayoutState extends State<MainLayout> with TickerProviderStateMixin {
|
|
|
|
|
const double timelinePadding = 60.0;
|
|
|
|
|
|
|
|
|
|
var timeline = Timeline(
|
|
|
|
|
numWeeks: dataToPlot != null && dataToPlot.length > 0
|
|
|
|
|
? dataToPlot.last.series.length
|
|
|
|
|
: 0,
|
|
|
|
|
numWeeks: dataToPlot.isNotEmpty ? dataToPlot.last.series.length : 0,
|
|
|
|
|
animationValue: interpolatedAnimationValue,
|
|
|
|
|
weekLabels: weekLabels,
|
|
|
|
|
mouseDownCallback: (double xFraction) {
|
|
|
|
|
setState(() {
|
|
|
|
|
timelineOverride = true;
|
|
|
|
|
_animation.stop();
|
|
|
|
|
_animation?.stop();
|
|
|
|
|
interpolatedAnimationValue = xFraction;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
@ -176,53 +176,55 @@ class _MainLayoutState extends State<MainLayout> with TickerProviderStateMixin {
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
_animation.dispose();
|
|
|
|
|
_animation?.dispose();
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future loadGitHubData() async {
|
|
|
|
|
String contributorsJsonStr =
|
|
|
|
|
(await http.get("assets/github_data/contributors.json")).body;
|
|
|
|
|
(await http.get(Uri.parse('assets/github_data/contributors.json')))
|
|
|
|
|
.body;
|
|
|
|
|
List jsonObjs = jsonDecode(contributorsJsonStr) as List;
|
|
|
|
|
List<UserContribution> contributionList =
|
|
|
|
|
jsonObjs.map((e) => UserContribution.fromJson(e)).toList();
|
|
|
|
|
print(
|
|
|
|
|
"Loaded ${contributionList.length} code contributions to /flutter/flutter repo.");
|
|
|
|
|
'Loaded ${contributionList.length} code contributions to /flutter/flutter repo.');
|
|
|
|
|
|
|
|
|
|
int numWeeksTotal = contributionList[0].contributions.length;
|
|
|
|
|
|
|
|
|
|
String starsByWeekStr =
|
|
|
|
|
(await http.get("assets/github_data/stars.tsv")).body;
|
|
|
|
|
(await http.get(Uri.parse('assets/github_data/stars.tsv'))).body;
|
|
|
|
|
List<StatForWeek> starsByWeekLoaded =
|
|
|
|
|
summarizeWeeksFromTSV(starsByWeekStr, numWeeksTotal);
|
|
|
|
|
|
|
|
|
|
String forksByWeekStr =
|
|
|
|
|
(await http.get("assets/github_data/forks.tsv")).body;
|
|
|
|
|
(await http.get(Uri.parse('assets/github_data/forks.tsv'))).body;
|
|
|
|
|
List<StatForWeek> forksByWeekLoaded =
|
|
|
|
|
summarizeWeeksFromTSV(forksByWeekStr, numWeeksTotal);
|
|
|
|
|
|
|
|
|
|
String commitsByWeekStr =
|
|
|
|
|
(await http.get("assets/github_data/commits.tsv")).body;
|
|
|
|
|
(await http.get(Uri.parse('assets/github_data/commits.tsv'))).body;
|
|
|
|
|
List<StatForWeek> commitsByWeekLoaded =
|
|
|
|
|
summarizeWeeksFromTSV(commitsByWeekStr, numWeeksTotal);
|
|
|
|
|
|
|
|
|
|
String commentsByWeekStr =
|
|
|
|
|
(await http.get("assets/github_data/comments.tsv")).body;
|
|
|
|
|
(await http.get(Uri.parse('assets/github_data/comments.tsv'))).body;
|
|
|
|
|
List<StatForWeek> commentsByWeekLoaded =
|
|
|
|
|
summarizeWeeksFromTSV(commentsByWeekStr, numWeeksTotal);
|
|
|
|
|
|
|
|
|
|
String pullRequestActivityByWeekStr =
|
|
|
|
|
(await http.get("assets/github_data/pull_requests.tsv")).body;
|
|
|
|
|
(await http.get(Uri.parse('assets/github_data/pull_requests.tsv')))
|
|
|
|
|
.body;
|
|
|
|
|
List<StatForWeek> pullRequestActivityByWeekLoaded =
|
|
|
|
|
summarizeWeeksFromTSV(pullRequestActivityByWeekStr, numWeeksTotal);
|
|
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
this.contributions = contributionList;
|
|
|
|
|
this.starsByWeek = starsByWeekLoaded;
|
|
|
|
|
this.forksByWeek = forksByWeekLoaded;
|
|
|
|
|
this.pushesByWeek = commitsByWeekLoaded;
|
|
|
|
|
this.issueCommentsByWeek = commentsByWeekLoaded;
|
|
|
|
|
this.pullRequestActivityByWeek = pullRequestActivityByWeekLoaded;
|
|
|
|
|
contributions = contributionList;
|
|
|
|
|
starsByWeek = starsByWeekLoaded;
|
|
|
|
|
forksByWeek = forksByWeekLoaded;
|
|
|
|
|
pushesByWeek = commitsByWeekLoaded;
|
|
|
|
|
issueCommentsByWeek = commentsByWeekLoaded;
|
|
|
|
|
pullRequestActivityByWeek = pullRequestActivityByWeekLoaded;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -230,18 +232,18 @@ class _MainLayoutState extends State<MainLayout> with TickerProviderStateMixin {
|
|
|
|
|
String statByWeekStr, int numWeeksTotal) {
|
|
|
|
|
List<StatForWeek> loadedStats = [];
|
|
|
|
|
HashMap<int, StatForWeek> statMap = HashMap();
|
|
|
|
|
statByWeekStr.split("\n").forEach((s) {
|
|
|
|
|
List<String> split = s.split("\t");
|
|
|
|
|
statByWeekStr.split('\n').forEach((s) {
|
|
|
|
|
List<String> split = s.split('\t');
|
|
|
|
|
if (split.length == 2) {
|
|
|
|
|
int weekNum = int.parse(split[0]);
|
|
|
|
|
statMap[weekNum] = StatForWeek(weekNum, int.parse(split[1]));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
print("Loaded ${statMap.length} weeks.");
|
|
|
|
|
print('Loaded ${statMap.length} weeks.');
|
|
|
|
|
|
|
|
|
|
// Convert into a list by week, but fill in empty weeks with 0
|
|
|
|
|
for (int i = 0; i < numWeeksTotal; i++) {
|
|
|
|
|
StatForWeek starsForWeek = statMap[i];
|
|
|
|
|
StatForWeek? starsForWeek = statMap[i];
|
|
|
|
|
if (starsForWeek == null) {
|
|
|
|
|
loadedStats.add(StatForWeek(i, 0));
|
|
|
|
|
} else {
|
|
|
|
@ -253,5 +255,5 @@ class _MainLayoutState extends State<MainLayout> with TickerProviderStateMixin {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
runApp(Center(child: MainLayout()));
|
|
|
|
|
runApp(const Center(child: MainLayout()));
|
|
|
|
|
}
|
|
|
|
|