Line data Source code
1 : // Copyright 2023 The terCAD team. All rights reserved.
2 : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.
3 :
4 : import 'package:app_finance/charts/painter/foreground_chart_painter.dart';
5 : import 'package:material_ui/material_ui.dart';
6 :
7 : abstract class AbstractPainter extends CustomPainter {
8 : final double indent;
9 : final double xMax;
10 : final double xMin;
11 : final double yMin;
12 : final double yMax;
13 : Size? size;
14 :
15 : final double msDay = 86400000;
16 :
17 1 : AbstractPainter({
18 : required this.indent,
19 : this.size,
20 : this.xMin = 0.0,
21 : this.xMax = 1.0,
22 : this.yMin = 0.0,
23 : this.yMax = 1.0,
24 : });
25 :
26 0 : @override
27 : bool shouldRepaint(CustomPainter oldDelegate) => false;
28 :
29 0 : Offset getValue(Offset point, Size size, [double dy = 0]) {
30 0 : double x = (point.dx - xMin) / (xMax - xMin) * size.width + indent;
31 0 : if (x > size.width) {
32 0 : x = size.width + 0.01;
33 0 : } else if (x < indent) {
34 0 : x = indent;
35 : }
36 0 : double y = (1 - (point.dy + dy - yMin) / (yMax - yMin)) * size.height - indent / ForegroundChartPainter.coercion;
37 0 : return Offset(x, y < 0 ? -0.01 : y);
38 : }
39 : }
|