forked from eatvio/eatvio_app
108 lines
3.3 KiB
Dart
108 lines
3.3 KiB
Dart
import 'package:eatvio_app/features/profile/models/profile_model.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:syncfusion_flutter_charts/charts.dart';
|
|
import 'package:intl/intl.dart';
|
|
|
|
class CircumferenceChartWidget extends StatelessWidget {
|
|
final List<Circumference> chartData;
|
|
|
|
const CircumferenceChartWidget({
|
|
super.key,
|
|
required this.chartData,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SfCartesianChart(
|
|
margin: EdgeInsets.zero,
|
|
enableAxisAnimation: true,
|
|
enableSideBySideSeriesPlacement: true,
|
|
legend: const Legend(
|
|
isVisible: true,
|
|
opacity: 0.7,
|
|
position: LegendPosition.bottom,
|
|
),
|
|
plotAreaBorderWidth: 0,
|
|
trackballBehavior: TrackballBehavior(
|
|
enable: true,
|
|
activationMode: ActivationMode.singleTap,
|
|
),
|
|
primaryXAxis: DateTimeAxis(
|
|
dateFormat: DateFormat.MMMd('ru'),
|
|
axisLine: AxisLine(
|
|
width: 1,
|
|
),
|
|
),
|
|
primaryYAxis: NumericAxis(
|
|
labelFormat: '{value} см',
|
|
axisLine: AxisLine(
|
|
width: 1,
|
|
),
|
|
majorTickLines: MajorTickLines(size: 0),
|
|
),
|
|
series: _getSplineSeries(),
|
|
tooltipBehavior: TooltipBehavior(enable: true),
|
|
);
|
|
}
|
|
|
|
List<CartesianSeries<Circumference, DateTime>> _getSplineSeries() {
|
|
final Color seriesColor1 = Colors.red;
|
|
final Color seriesColor2 = Colors.blue;
|
|
final Color seriesColor3 = Colors.green;
|
|
|
|
return <CartesianSeries<Circumference, DateTime>>[
|
|
SplineSeries<Circumference, DateTime>(
|
|
markerSettings: MarkerSettings(
|
|
isVisible: true,
|
|
color: seriesColor1,
|
|
height: 12,
|
|
width: 12,
|
|
),
|
|
dataLabelSettings: DataLabelSettings(
|
|
labelAlignment: ChartDataLabelAlignment.top,
|
|
isVisible: true,
|
|
),
|
|
dataSource: chartData,
|
|
color: seriesColor1,
|
|
name: 'Грудь',
|
|
xValueMapper: (Circumference value, int index) => value.createdAt,
|
|
yValueMapper: (Circumference value, int index) => value.chestCircumference,
|
|
),
|
|
SplineSeries<Circumference, DateTime>(
|
|
markerSettings: MarkerSettings(
|
|
isVisible: true,
|
|
color: seriesColor2,
|
|
height: 12,
|
|
width: 12,
|
|
),
|
|
dataLabelSettings: DataLabelSettings(
|
|
labelAlignment: ChartDataLabelAlignment.top,
|
|
isVisible: true,
|
|
),
|
|
dataSource: chartData,
|
|
color: seriesColor2,
|
|
name: 'Талия',
|
|
xValueMapper: (Circumference value, int index) => value.createdAt,
|
|
yValueMapper: (Circumference value, int index) => value.waistCircumference,
|
|
),
|
|
SplineSeries<Circumference, DateTime>(
|
|
markerSettings: MarkerSettings(
|
|
isVisible: true,
|
|
color: seriesColor3,
|
|
height: 12,
|
|
width: 12,
|
|
),
|
|
dataLabelSettings: DataLabelSettings(
|
|
labelAlignment: ChartDataLabelAlignment.top,
|
|
isVisible: true,
|
|
),
|
|
dataSource: chartData,
|
|
color: seriesColor3,
|
|
name: 'Бёдра',
|
|
xValueMapper: (Circumference value, int index) => value.createdAt,
|
|
yValueMapper: (Circumference value, int index) => value.hipCircumference,
|
|
),
|
|
];
|
|
}
|
|
}
|