Я печатаю пользовательскую диаграмму пончиков. И я не могу добавить границу в каждый элемент < /p>
class DonutChartPainter extends CustomPainter {
final double planCalories;
final double leftCalories;
final double thickness = 40;
DonutChartPainter(this.planCalories, this.leftCalories);
@override
void paint(Canvas canvas, Size size) {
final Paint fillPaint = Paint()
..style = PaintingStyle.stroke
..strokeWidth = thickness
..strokeCap = StrokeCap.butt;
final Paint borderPaint = Paint()
..color = Colors.black
..style = PaintingStyle.stroke
..strokeWidth = 1;
final double radius = size.width / 2;
final Offset center = Offset(size.width / 2, size.height / 2);
final double usedCalories = planCalories - leftCalories;
final double leftAngle = (leftCalories / planCalories) * 2 * pi;
final double usedAngle = (usedCalories / planCalories) * 2 * pi;
final double separationOffset = 10;
final Offset usedCenter = Offset(center.dx + separationOffset * cos(-pi / 2 + usedAngle / 2),
center.dy + separationOffset * sin(-pi / 2 + usedAngle / 2));
final Offset leftCenter = Offset(center.dx + separationOffset * cos(-pi / 2 + usedAngle + leftAngle / 2),
center.dy + separationOffset * sin(-pi / 2 + usedAngle + leftAngle / 2));
Rect usedOvalRect = Rect.fromCircle(center: usedCenter, radius: radius - thickness / 2);
Rect leftOvalRect = Rect.fromCircle(center: leftCenter, radius: radius - thickness / 2);
fillPaint.color = green;
canvas.drawArc(usedOvalRect, -pi / 2, usedAngle, false, fillPaint);
fillPaint.color = lightGreen;
canvas.drawArc(leftOvalRect, -pi / 2 + usedAngle, leftAngle, false, fillPaint);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
}
< /code>
Как это похоже на^ my -chart < /p>
Когда я добавляю этот код в конце < /p>
canvas.drawArc(usedOvalRect, -pi / 2, usedAngle, false, borderPaint);
canvas.drawArc(leftOvalRect, -pi / 2 + usedAngle, leftAngle, false, borderPaint);
< /code>
Похоже, что 2 < /p>
Но мне нужна граница
Мне нужно добавить отдельную черную границу в каждый элемент на панели, чтобы сделать их более контрастными
Подробнее здесь: https://stackoverflow.com/questions/794 ... ar-flutter
Как добавить границу в диаграмму пончиков. ⇐ Android
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Можно ли добавить радиус углового радиуса в диаграмму пончиков в Victory-Native-XL?
Anonymous » » в форуме Android - 0 Ответы
- 8 Просмотры
-
Последнее сообщение Anonymous
-