buildSimpleChart function
Build a simple single-line chart widget.
Implementation
Widget buildSimpleChart({
required Map<DateTime, double> chartData,
required double dataMin,
required double dataMax,
required String dataType,
}) {
// Determine color based on data type.
Color lineColor = Colors.blue; // Default color
if (dataType == 'humidity') {
lineColor = Colors.red; // Red for humidity
} else if (dataType == 'precipitation') {
lineColor = Colors.blue; // Blue for precipitation
}
return SizedBox(
height: 200,
child: CustomPaint(
painter: WeatherChartPainter(
dailyAverages: chartData,
minValue: dataMin,
maxValue: dataMax,
color: lineColor,
),
size: const Size(double.infinity, 200),
),
);
}