optimization of the detection algorithem.
BOOK update.
This commit is contained in:
@@ -27,6 +27,9 @@ class ProgressChart extends StatefulWidget {
|
||||
final List<ChartSeries> series; // legend and tooltip order
|
||||
final Color textColor;
|
||||
final Color gridColor;
|
||||
// true: the graph takes all the height its parent gives it (inside an
|
||||
// Expanded); false: a fixed 190 px
|
||||
final bool expand;
|
||||
|
||||
const ProgressChart({
|
||||
super.key,
|
||||
@@ -34,6 +37,7 @@ class ProgressChart extends StatefulWidget {
|
||||
required this.series,
|
||||
required this.textColor,
|
||||
required this.gridColor,
|
||||
this.expand = false,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -78,29 +82,32 @@ class _ProgressChartState extends State<ProgressChart> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final graph = LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final size = Size(
|
||||
constraints.maxWidth, widget.expand ? constraints.maxHeight : 190);
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTapDown: (d) => _toggle(d.localPosition, size),
|
||||
onHorizontalDragUpdate: (d) => _select(d.localPosition, size),
|
||||
child: CustomPaint(
|
||||
size: size,
|
||||
painter: _ChartPainter(
|
||||
labels: widget.labels,
|
||||
series: widget.series,
|
||||
textColor: widget.textColor,
|
||||
gridColor: widget.gridColor,
|
||||
selected: _selected,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
mainAxisSize: widget.expand ? MainAxisSize.max : MainAxisSize.min,
|
||||
children: [
|
||||
LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final size = Size(constraints.maxWidth, 190);
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTapDown: (d) => _toggle(d.localPosition, size),
|
||||
onHorizontalDragUpdate: (d) => _select(d.localPosition, size),
|
||||
child: CustomPaint(
|
||||
size: size,
|
||||
painter: _ChartPainter(
|
||||
labels: widget.labels,
|
||||
series: widget.series,
|
||||
textColor: widget.textColor,
|
||||
gridColor: widget.gridColor,
|
||||
selected: _selected,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
widget.expand ? Expanded(child: graph) : graph,
|
||||
const SizedBox(height: 8),
|
||||
// Legend, centred under the graph
|
||||
Wrap(
|
||||
|
||||
Reference in New Issue
Block a user