mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
SP-1723-FE-Integrate-Charts-with-API-s-for-AQI-sensor. (#258)
<!-- Thanks for contributing! Provide a description of your changes below and a general summary in the title Please look at the following checklist to ensure that your PR can be accepted quickly: --> ## Jira Ticket [SP-1732](https://syncrow.atlassian.net/browse/SP-1732) ## Description changed occupancy heat map graident alignment, and increased opacity for low values cells in the heatmap. ## Type of Change <!--- Put an `x` in all the boxes that apply: --> - [ ] ✨ New feature (non-breaking change which adds functionality) - [x] 🛠️ Bug fix (non-breaking change which fixes an issue) - [ ] ❌ Breaking change (fix or feature that would cause existing functionality to change) - [ ] 🧹 Code refactor - [ ] ✅ Build configuration change - [ ] 📝 Documentation - [ ] 🗑️ Chore [SP-1732]: https://syncrow.atlassian.net/browse/SP-1732?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
This commit is contained in:
@ -34,8 +34,8 @@ class OccupancyHeatMapGradient extends StatelessWidget {
|
|||||||
width: 1,
|
width: 1,
|
||||||
),
|
),
|
||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
begin: AlignmentDirectional.centerEnd,
|
begin: AlignmentDirectional.centerStart,
|
||||||
end: AlignmentDirectional.centerStart,
|
end: AlignmentDirectional.centerEnd,
|
||||||
colors: _heatMapColors(),
|
colors: _heatMapColors(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -28,11 +28,11 @@ class OccupancyPainter extends CustomPainter {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void paint(Canvas canvas, Size size) {
|
void paint(Canvas canvas, Size size) {
|
||||||
final Paint fillPaint = Paint();
|
final fillPaint = Paint();
|
||||||
final Paint borderPaint = Paint()
|
final borderPaint = Paint()
|
||||||
..color = ColorsManager.grayBorder.withValues(alpha: 0.4)
|
..color = ColorsManager.grayBorder.withValues(alpha: 0.4)
|
||||||
..style = PaintingStyle.stroke;
|
..style = PaintingStyle.stroke;
|
||||||
final Paint hoveredBorderPaint = Paint()
|
final hoveredBorderPaint = Paint()
|
||||||
..color = Colors.black
|
..color = Colors.black
|
||||||
..style = PaintingStyle.stroke
|
..style = PaintingStyle.stroke
|
||||||
..strokeWidth = 1.5;
|
..strokeWidth = 1.5;
|
||||||
@ -48,7 +48,6 @@ class OccupancyPainter extends CustomPainter {
|
|||||||
final rect = Rect.fromLTWH(x, y, cellSize, cellSize);
|
final rect = Rect.fromLTWH(x, y, cellSize, cellSize);
|
||||||
canvas.drawRect(rect, fillPaint);
|
canvas.drawRect(rect, fillPaint);
|
||||||
|
|
||||||
// Highlight the hovered item
|
|
||||||
if (hoveredItem != null && hoveredItem!.index == item.index) {
|
if (hoveredItem != null && hoveredItem!.index == item.index) {
|
||||||
canvas.drawRect(rect, hoveredBorderPaint);
|
canvas.drawRect(rect, hoveredBorderPaint);
|
||||||
} else {
|
} else {
|
||||||
@ -73,16 +72,16 @@ class OccupancyPainter extends CustomPainter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _drawDashedLine(Canvas canvas, Offset start, Offset end, Paint paint) {
|
void _drawDashedLine(Canvas canvas, Offset start, Offset end, Paint paint) {
|
||||||
const double dashWidth = 2.0;
|
const dashWidth = 2.0;
|
||||||
const double dashSpace = 4.0;
|
const dashSpace = 4.0;
|
||||||
final double totalLength = (end - start).distance;
|
final totalLength = (end - start).distance;
|
||||||
final Offset direction = (end - start) / (end - start).distance;
|
final direction = (end - start) / (end - start).distance;
|
||||||
|
|
||||||
double currentLength = 0.0;
|
var currentLength = 0.0;
|
||||||
while (currentLength < totalLength) {
|
while (currentLength < totalLength) {
|
||||||
final Offset dashStart = start + direction * currentLength;
|
final dashStart = start + direction * currentLength;
|
||||||
final double nextLength = currentLength + dashWidth;
|
final nextLength = currentLength + dashWidth;
|
||||||
final Offset dashEnd =
|
final dashEnd =
|
||||||
start + direction * (nextLength < totalLength ? nextLength : totalLength);
|
start + direction * (nextLength < totalLength ? nextLength : totalLength);
|
||||||
canvas.drawLine(dashStart, dashEnd, paint);
|
canvas.drawLine(dashStart, dashEnd, paint);
|
||||||
currentLength = nextLength + dashSpace;
|
currentLength = nextLength + dashSpace;
|
||||||
@ -91,8 +90,9 @@ class OccupancyPainter extends CustomPainter {
|
|||||||
|
|
||||||
Color _getColor(int value) {
|
Color _getColor(int value) {
|
||||||
if (maxValue == 0) return ColorsManager.vividBlue.withValues(alpha: 0);
|
if (maxValue == 0) return ColorsManager.vividBlue.withValues(alpha: 0);
|
||||||
final opacity = value.clamp(0, maxValue) / maxValue;
|
final clampedValue = 0.075 + (1 * value.clamp(0, maxValue) / maxValue);
|
||||||
return ColorsManager.vividBlue.withValues(alpha: opacity);
|
final opacity = value == 0 ? 0 : clampedValue;
|
||||||
|
return ColorsManager.vividBlue.withValues(alpha: opacity.toDouble());
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
Reference in New Issue
Block a user