mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
Implemented the overall design of RangeOfAqiChart
, whats left is 100% matching it with the figma design.
This commit is contained in:
@ -15,75 +15,45 @@ class RangeOfAqiChart extends StatelessWidget {
|
||||
required this.maxValues,
|
||||
});
|
||||
|
||||
static const _gradientColors = [
|
||||
ColorsManager.goodGreen,
|
||||
ColorsManager.moderateYellow,
|
||||
ColorsManager.poorOrange,
|
||||
ColorsManager.unhealthyRed,
|
||||
ColorsManager.severePink,
|
||||
ColorsManager.hazardousPurple,
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
children: [
|
||||
// Fixed gradient background
|
||||
Positioned.fill(
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.bottomCenter,
|
||||
end: Alignment.topCenter,
|
||||
colors: [
|
||||
Color(0xFF0CEC16),
|
||||
Color(0xFFFAC96C),
|
||||
Color(0xFFEC7400),
|
||||
Color(0xFFD40000),
|
||||
Color(0xFFD40094),
|
||||
Color(0xFFBA01FD),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
LineChart(
|
||||
LineChartData(
|
||||
minY: 0,
|
||||
maxY: 320,
|
||||
maxY: 301,
|
||||
gridData: EnergyManagementChartsHelper.gridData(),
|
||||
titlesData: EnergyManagementChartsHelper.titlesData(context),
|
||||
borderData: FlBorderData(show: false),
|
||||
borderData: EnergyManagementChartsHelper.borderData(),
|
||||
betweenBarsData: [
|
||||
BetweenBarsData(
|
||||
fromIndex: 0,
|
||||
toIndex: 2,
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.bottomCenter,
|
||||
end: Alignment.topCenter,
|
||||
colors: _gradientColors
|
||||
.map(
|
||||
(e) => e.withValues(alpha: 0.8),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
lineBarsData: [
|
||||
// Max line (top, purple)
|
||||
LineChartBarData(
|
||||
spots: List.generate(
|
||||
maxValues.length,
|
||||
(i) => FlSpot(i.toDouble(), maxValues[i]),
|
||||
),
|
||||
isCurved: true,
|
||||
color: const Color(0xFF962DFF),
|
||||
barWidth: 3,
|
||||
isStrokeCapRound: true,
|
||||
dotData: _buildDotData(const Color(0xFF5F00BD)),
|
||||
belowBarData: BarAreaData(show: false),
|
||||
),
|
||||
// Avg line (middle, white)
|
||||
LineChartBarData(
|
||||
spots: List.generate(
|
||||
avgValues.length,
|
||||
(i) => FlSpot(i.toDouble(), avgValues[i]),
|
||||
),
|
||||
isCurved: true,
|
||||
color: Colors.white,
|
||||
barWidth: 3,
|
||||
dotData: const FlDotData(show: false),
|
||||
belowBarData: BarAreaData(show: false),
|
||||
),
|
||||
// Min line (bottom, blue)
|
||||
LineChartBarData(
|
||||
spots: List.generate(
|
||||
minValues.length,
|
||||
(i) => FlSpot(i.toDouble(), minValues[i]),
|
||||
),
|
||||
isCurved: true,
|
||||
color: const Color(0xFF93AAFD),
|
||||
barWidth: 3,
|
||||
isStrokeCapRound: true,
|
||||
dotData: _buildDotData(const Color(0xFF023DFE)),
|
||||
belowBarData: BarAreaData(show: false),
|
||||
),
|
||||
_buildMaxLine(),
|
||||
_buildAverageLine(),
|
||||
_buildMinLine(),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -91,6 +61,50 @@ class RangeOfAqiChart extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
LineChartBarData _buildMinLine() {
|
||||
return LineChartBarData(
|
||||
spots: List.generate(
|
||||
minValues.length,
|
||||
(i) => FlSpot(i.toDouble(), minValues[i]),
|
||||
),
|
||||
isCurved: true,
|
||||
color: const Color(0xFF93AAFD),
|
||||
barWidth: 3,
|
||||
isStrokeCapRound: true,
|
||||
dotData: _buildDotData(const Color(0xFF023DFE)),
|
||||
belowBarData: BarAreaData(show: false),
|
||||
);
|
||||
}
|
||||
|
||||
LineChartBarData _buildAverageLine() {
|
||||
return LineChartBarData(
|
||||
spots: List.generate(
|
||||
avgValues.length,
|
||||
(i) => FlSpot(i.toDouble(), avgValues[i]),
|
||||
),
|
||||
isCurved: true,
|
||||
color: Colors.white,
|
||||
barWidth: 3,
|
||||
dotData: const FlDotData(show: false),
|
||||
belowBarData: BarAreaData(show: false),
|
||||
);
|
||||
}
|
||||
|
||||
LineChartBarData _buildMaxLine() {
|
||||
return LineChartBarData(
|
||||
spots: List.generate(
|
||||
maxValues.length,
|
||||
(i) => FlSpot(i.toDouble(), maxValues[i]),
|
||||
),
|
||||
isCurved: true,
|
||||
color: const Color(0xFF962DFF),
|
||||
barWidth: 3,
|
||||
isStrokeCapRound: true,
|
||||
dotData: _buildDotData(const Color(0xFF5F00BD)),
|
||||
belowBarData: BarAreaData(show: false),
|
||||
);
|
||||
}
|
||||
|
||||
FlDotData _buildDotData(Color color) {
|
||||
return FlDotData(
|
||||
show: true,
|
||||
|
Reference in New Issue
Block a user