Merge pull request #396 from koying/history_tweak

History tweaks
This commit is contained in:
Yegor Vialov 2019-08-30 19:48:04 +03:00 committed by GitHub
commit e858eee83b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 4 deletions

View File

@ -148,7 +148,7 @@ class _CombinedHistoryChartWidgetState extends State<CombinedHistoryChartWidget>
}); });
if ((_selectedId == -1) && (numericDataLists.isNotEmpty)) { if ((_selectedId == -1) && (numericDataLists.isNotEmpty)) {
_selectedId = 0; _selectedId = numericDataLists.length -1;
} }
List<charts.Series<EntityHistoryMoment, DateTime>> result = []; List<charts.Series<EntityHistoryMoment, DateTime>> result = [];
numericDataLists.forEach((attrName, dataList) { numericDataLists.forEach((attrName, dataList) {
@ -202,6 +202,11 @@ class _CombinedHistoryChartWidgetState extends State<CombinedHistoryChartWidget>
_selectedId -= 1; _selectedId -= 1;
}); });
} }
else {
setState(() {
_selectedId = _parsedHistory.first.data.length - 1;
});
}
} }
void _selectNext() { void _selectNext() {
@ -210,6 +215,12 @@ class _CombinedHistoryChartWidgetState extends State<CombinedHistoryChartWidget>
_selectedId += 1; _selectedId += 1;
}); });
} }
else {
setState(() {
_selectedId = 0;
});
}
} }
void _onSelectionChanged(charts.SelectionModel model) { void _onSelectionChanged(charts.SelectionModel model) {

View File

@ -103,7 +103,7 @@ class _NumericStateHistoryChartWidgetState extends State<NumericStateHistoryChar
id: widget.rawHistory.length id: widget.rawHistory.length
)); ));
if (_selectedId == -1) { if (_selectedId == -1) {
_selectedId = 0; _selectedId = data.length - 1;
} }
return [ return [
new charts.Series<EntityHistoryMoment, DateTime>( new charts.Series<EntityHistoryMoment, DateTime>(
@ -132,6 +132,11 @@ class _NumericStateHistoryChartWidgetState extends State<NumericStateHistoryChar
_selectedId -= 1; _selectedId -= 1;
}); });
} }
else {
setState(() {
_selectedId = _parsedHistory.first.data.length - 1;
});
}
} }
void _selectNext() { void _selectNext() {
@ -140,6 +145,12 @@ class _NumericStateHistoryChartWidgetState extends State<NumericStateHistoryChar
_selectedId += 1; _selectedId += 1;
}); });
} }
else {
setState(() {
_selectedId = 0;
});
}
} }
void _onSelectionChanged(charts.SelectionModel model) { void _onSelectionChanged(charts.SelectionModel model) {

View File

@ -101,7 +101,7 @@ class _SimpleStateHistoryChartWidgetState extends State<SimpleStateHistoryChartW
colorId: data.last.colorId colorId: data.last.colorId
)); ));
if (_selectedId == -1) { if (_selectedId == -1) {
_selectedId = 0; _selectedId = data.length - 1;
} }
return [ return [
new charts.Series<EntityHistoryMoment, DateTime>( new charts.Series<EntityHistoryMoment, DateTime>(
@ -137,14 +137,25 @@ class _SimpleStateHistoryChartWidgetState extends State<SimpleStateHistoryChartW
_selectedId -= 1; _selectedId -= 1;
}); });
} }
else {
setState(() {
_selectedId = _parsedHistory.first.data.length - 1;
});
}
} }
void _selectNext() { void _selectNext() {
if (_selectedId < (_parsedHistory.first.data.length - 2)) { if (_selectedId < (_parsedHistory.first.data.length - 1)) {
setState(() { setState(() {
_selectedId += 1; _selectedId += 1;
}); });
} }
else {
setState(() {
_selectedId = 0;
});
}
} }
void _onSelectionChanged(charts.SelectionModel model) { void _onSelectionChanged(charts.SelectionModel model) {