forked from eatvio/eatvio_app
70 lines
2.0 KiB
Dart
70 lines
2.0 KiB
Dart
import 'package:eatvio_app/features/profile/models/profile_model.dart' as ProfileModel;
|
|
import 'package:flutter/material.dart';
|
|
import 'package:syncfusion_flutter_charts/charts.dart';
|
|
import 'package:intl/intl.dart';
|
|
|
|
class ImtChartWidget extends StatelessWidget {
|
|
final List<ProfileModel.ChartPoint> chartPoints;
|
|
|
|
const ImtChartWidget({
|
|
super.key,
|
|
required this.chartPoints,
|
|
});
|
|
|
|
@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<ProfileModel.ChartPoint, DateTime>> _getSplineSeries() {
|
|
return <CartesianSeries<ProfileModel.ChartPoint, DateTime>>[
|
|
SplineSeries<ProfileModel.ChartPoint, DateTime>(
|
|
markerSettings: MarkerSettings(
|
|
isVisible: true,
|
|
color: Colors.blue,
|
|
height: 12,
|
|
width: 12,
|
|
),
|
|
dataLabelSettings: DataLabelSettings(
|
|
labelAlignment: ChartDataLabelAlignment.top,
|
|
isVisible: true,
|
|
),
|
|
dataSource: chartPoints,
|
|
color: Colors.blue,
|
|
name: 'ИМТ',
|
|
xValueMapper: (ProfileModel.ChartPoint value, int index) => value.createdAt,
|
|
yValueMapper: (ProfileModel.ChartPoint value, int index) => double.parse(value.bmi),
|
|
),
|
|
];
|
|
}
|
|
}
|