|
...
|
...
|
@@ -520,21 +520,6 @@ class _DurationChartState extends State<_DurationChart> { |
|
|
|
alignment: Alignment.center,
|
|
|
|
clipBehavior: Clip.none,
|
|
|
|
children: [
|
|
|
|
if (_selectedIndex != null && _selectedOffset != null)
|
|
|
|
Positioned.fill(
|
|
|
|
child: LayoutBuilder(
|
|
|
|
builder: (context, constraints) =>
|
|
|
|
ChartSelectionLineOverlay(
|
|
|
|
offset: Offset.zero,
|
|
|
|
color: SleepWeekReportView.h3,
|
|
|
|
bottomTitleHeight: _ChartPlotFrame.bottomTitleHeight,
|
|
|
|
plotLeft: 0,
|
|
|
|
plotRight: 0,
|
|
|
|
lineX: _selectedOffset!.dx,
|
|
|
|
lineTop: _fixedTooltipBottom,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
_ChartPlotFrame(
|
|
|
|
maxY: _maxY,
|
|
|
|
interval: 2,
|
|
...
|
...
|
@@ -566,15 +551,25 @@ class _DurationChartState extends State<_DurationChart> { |
|
|
|
),
|
|
|
|
onPointerUp: (_) => _onSelected(null, null),
|
|
|
|
onPointerCancel: (_) => _onSelected(null, null),
|
|
|
|
child: BarChart(
|
|
|
|
_chartData(
|
|
|
|
constraints.maxWidth,
|
|
|
|
constraints.maxHeight,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: BarChart(_chartData(constraints.maxWidth)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (_selectedIndex != null && _selectedOffset != null)
|
|
|
|
Positioned.fill(
|
|
|
|
child: LayoutBuilder(
|
|
|
|
builder: (context, constraints) =>
|
|
|
|
ChartSelectionLineOverlay(
|
|
|
|
offset: Offset.zero,
|
|
|
|
color: SleepWeekReportView.h3,
|
|
|
|
bottomTitleHeight: _ChartPlotFrame.bottomTitleHeight,
|
|
|
|
plotLeft: 0,
|
|
|
|
plotRight: 0,
|
|
|
|
lineX: _selectedOffset!.dx,
|
|
|
|
lineTop: -_barTooltipMargin,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (!hasData) const _WaitingDataText(),
|
|
|
|
],
|
|
|
|
),
|
|
...
|
...
|
@@ -583,7 +578,7 @@ class _DurationChartState extends State<_DurationChart> { |
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
BarChartData _chartData(double plotWidth, double chartHeight) {
|
|
|
|
BarChartData _chartData(double plotWidth) {
|
|
|
|
return BarChartData(
|
|
|
|
minY: 0,
|
|
|
|
maxY: _maxY,
|
|
...
|
...
|
@@ -624,11 +619,7 @@ class _DurationChartState extends State<_DurationChart> { |
|
|
|
),
|
|
|
|
),
|
|
|
|
BarChartRodData(
|
|
|
|
toY: _tooltipAnchorValue(
|
|
|
|
maxY: _maxY,
|
|
|
|
chartHeight: chartHeight,
|
|
|
|
tooltipMargin: _barTooltipMargin,
|
|
|
|
),
|
|
|
|
toY: _maxY,
|
|
|
|
width: 0,
|
|
|
|
color: Colors.transparent,
|
|
|
|
),
|
|
...
|
...
|
@@ -738,21 +729,6 @@ class _QualityChartState extends State<_QualityChart> { |
|
|
|
alignment: Alignment.center,
|
|
|
|
clipBehavior: Clip.none,
|
|
|
|
children: [
|
|
|
|
if (_selectedIndex != null && _selectedOffset != null)
|
|
|
|
Positioned.fill(
|
|
|
|
child: LayoutBuilder(
|
|
|
|
builder: (context, constraints) =>
|
|
|
|
ChartSelectionLineOverlay(
|
|
|
|
offset: Offset.zero,
|
|
|
|
color: SleepWeekReportView.h3,
|
|
|
|
bottomTitleHeight: _ChartPlotFrame.bottomTitleHeight,
|
|
|
|
plotLeft: 0,
|
|
|
|
plotRight: 0,
|
|
|
|
lineX: _selectedOffset!.dx,
|
|
|
|
lineTop: _fixedTooltipBottom,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
_ChartPlotFrame(
|
|
|
|
maxY: 100,
|
|
|
|
interval: 25,
|
|
...
|
...
|
@@ -778,15 +754,25 @@ class _QualityChartState extends State<_QualityChart> { |
|
|
|
),
|
|
|
|
onPointerUp: (_) => _onSelected(null, null),
|
|
|
|
onPointerCancel: (_) => _onSelected(null, null),
|
|
|
|
child: BarChart(
|
|
|
|
_chartData(
|
|
|
|
constraints.maxWidth,
|
|
|
|
constraints.maxHeight,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: BarChart(_chartData(constraints.maxWidth)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (_selectedIndex != null && _selectedOffset != null)
|
|
|
|
Positioned.fill(
|
|
|
|
child: LayoutBuilder(
|
|
|
|
builder: (context, constraints) =>
|
|
|
|
ChartSelectionLineOverlay(
|
|
|
|
offset: Offset.zero,
|
|
|
|
color: SleepWeekReportView.h3,
|
|
|
|
bottomTitleHeight: _ChartPlotFrame.bottomTitleHeight,
|
|
|
|
plotLeft: 0,
|
|
|
|
plotRight: 0,
|
|
|
|
lineX: _selectedOffset!.dx,
|
|
|
|
lineTop: -_barTooltipMargin,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (!hasData) const _WaitingDataText(),
|
|
|
|
],
|
|
|
|
),
|
|
...
|
...
|
@@ -795,7 +781,7 @@ class _QualityChartState extends State<_QualityChart> { |
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
BarChartData _chartData(double plotWidth, double chartHeight) {
|
|
|
|
BarChartData _chartData(double plotWidth) {
|
|
|
|
return BarChartData(
|
|
|
|
minY: 0,
|
|
|
|
maxY: 100,
|
|
...
|
...
|
@@ -835,11 +821,7 @@ class _QualityChartState extends State<_QualityChart> { |
|
|
|
),
|
|
|
|
),
|
|
|
|
BarChartRodData(
|
|
|
|
toY: _tooltipAnchorValue(
|
|
|
|
maxY: 100,
|
|
|
|
chartHeight: chartHeight,
|
|
|
|
tooltipMargin: _barTooltipMargin,
|
|
|
|
),
|
|
|
|
toY: 100,
|
|
|
|
width: 0,
|
|
|
|
color: Colors.transparent,
|
|
|
|
),
|
|
...
|
...
|
@@ -964,14 +946,14 @@ class _BedtimeChartState extends State<_BedtimeChart> { |
|
|
|
constraints.maxWidth,
|
|
|
|
_selectedDayIndex!,
|
|
|
|
),
|
|
|
|
lineTop: _fixedTooltipBottom,
|
|
|
|
lineTop: _bedtimeChartTopInset,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
_ChartPlotFrame(
|
|
|
|
maxY: axis.maxHour.toDouble(),
|
|
|
|
minY: axis.minHour.toDouble(),
|
|
|
|
interval: 1,
|
|
|
|
topInset: 16,
|
|
|
|
topInset: _bedtimeChartTopInset,
|
|
|
|
insetChildHorizontally: false,
|
|
|
|
rightLabel: _timeAxisLabel,
|
|
|
|
child: LayoutBuilder(
|
|
...
|
...
|
@@ -991,7 +973,6 @@ class _BedtimeChartState extends State<_BedtimeChart> { |
|
|
|
_chartData(
|
|
|
|
axis,
|
|
|
|
constraints.maxWidth,
|
|
|
|
constraints.maxHeight,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
...
|
...
|
@@ -1015,7 +996,6 @@ class _BedtimeChartState extends State<_BedtimeChart> { |
|
|
|
LineChartData _chartData(
|
|
|
|
_BedtimeAxis axis,
|
|
|
|
double chartWidth,
|
|
|
|
double chartHeight,
|
|
|
|
) {
|
|
|
|
final points = <FlSpot>[
|
|
|
|
for (var i = 0; i < widget.days.length; i++)
|
|
...
|
...
|
@@ -1049,16 +1029,7 @@ class _BedtimeChartState extends State<_BedtimeChart> { |
|
|
|
);
|
|
|
|
final anchorData = LineChartBarData(
|
|
|
|
spots: [
|
|
|
|
for (final point in points)
|
|
|
|
FlSpot(
|
|
|
|
point.x,
|
|
|
|
_tooltipAnchorValue(
|
|
|
|
maxY: _tooltipChartMaxY,
|
|
|
|
chartHeight: chartHeight,
|
|
|
|
tooltipMargin: _tooltipMargin,
|
|
|
|
chartTopInset: 16,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
for (final point in points) FlSpot(point.x, _tooltipChartMaxY),
|
|
|
|
],
|
|
|
|
color: Colors.transparent,
|
|
|
|
barWidth: 0,
|
|
...
|
...
|
@@ -1160,22 +1131,9 @@ const _weekBarGap = 28.0; |
|
|
|
const _monthHorizontalInsets = 46.0;
|
|
|
|
|
|
|
|
const _tooltipChartMaxY = 110.0;
|
|
|
|
const _tooltipMargin = 16.0;
|
|
|
|
const _bedtimeTooltipMargin = 0.0;
|
|
|
|
const _barTooltipMargin = 6.0;
|
|
|
|
const _fixedTooltipBottom = 64.0;
|
|
|
|
|
|
|
|
double _tooltipAnchorValue({
|
|
|
|
required double maxY,
|
|
|
|
required double chartHeight,
|
|
|
|
required double tooltipMargin,
|
|
|
|
double chartTopInset = 0,
|
|
|
|
}) {
|
|
|
|
final plotHeight = chartHeight - _ChartPlotFrame.bottomTitleHeight;
|
|
|
|
if (plotHeight <= 0) return maxY;
|
|
|
|
final anchorY = (_fixedTooltipBottom - chartTopInset + tooltipMargin)
|
|
|
|
.clamp(0, plotHeight);
|
|
|
|
return (maxY * (1 - anchorY / plotHeight)).clamp(0, maxY);
|
|
|
|
}
|
|
|
|
const _bedtimeChartTopInset = 16.0;
|
|
|
|
|
|
|
|
double _barGroupsSpace(double plotWidth, int count, bool compact) {
|
|
|
|
if (count <= 1) return 0;
|
|
...
|
...
|
@@ -1351,7 +1309,7 @@ LineTouchTooltipData _lineTooltipData({ |
|
|
|
tooltipBorder: BorderSide.none,
|
|
|
|
getTooltipColor: (_) => SleepWeekReportView.grid,
|
|
|
|
tooltipPadding: const EdgeInsets.fromLTRB(8, 7, 8, 6),
|
|
|
|
tooltipMargin: 16,
|
|
|
|
tooltipMargin: _bedtimeTooltipMargin,
|
|
|
|
fitInsideHorizontally: true,
|
|
|
|
fitInsideVertically: false,
|
|
|
|
showOnTopOfTheChartBoxArea: false,
|
...
|
...
|
|