Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Commit

Permalink
added opcaity and counter color (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggalambas authored Apr 1, 2024
1 parent 856344e commit 92a3b9b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 11 deletions.
6 changes: 6 additions & 0 deletions packages/atlas/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# atlas

## v1.1.0 (2024-04-01)

- Added parameter `opacity` for `Heatmaps`
- Changed parameters `heatpoints` to `points` for `Heatmaps`
- Changed parameters `heatcolor` to `color` for `Heatmaps`

## v1.0.22 (2024-03-21)

- Added support for `Heatmaps`
Expand Down
25 changes: 21 additions & 4 deletions packages/atlas/lib/src/heatmap/heatmap.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
import 'package:atlas/src/heatmap/heatcolor.dart';
import 'package:flutter/material.dart';

import 'heatpoint.dart';

/// Visualization to depict the intensity of data at geographical points.
class Heatmap {
final Set<Heatpoint> heatpoints;
final Heatcolor? heatcolor;
/// The points where to build the heatmaps
final Set<Heatpoint> points;

/// Defines the color of each pixel based on its density value in a heatmap
final Heatcolor? color;

/// The global opacity at which the heatmap layer will be drawn.
final double opacity;

/// Whether to show or not the counter of points
final bool showCounter;

const Heatmap({required this.heatpoints, this.heatcolor, this.showCounter = false});
/// The color with which the counter will be drawn.
final Color counterColor;

const Heatmap({
required this.points,
this.color,
this.opacity = 1,
this.showCounter = false,
this.counterColor = Colors.black,
});
}
2 changes: 1 addition & 1 deletion packages/atlas/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: atlas
description: An extensible map abstraction for Flutter with support for multiple map providers
version: 1.0.22
version: 1.1.0
repository: https://github.com/bmw-tech/atlas
issue_tracker: https://github.com/bmw-tech/atlas/issues
homepage: https://bmw-tech.github.io/atlas
Expand Down
22 changes: 16 additions & 6 deletions packages/atlas/test/heatmap/heatmap_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ void main() {
Heatpoint(id: '1', position: LatLng(latitude: 37.7749, longitude: -122.4194), counter: 10),
Heatpoint(id: '2', position: LatLng(latitude: 34.0522, longitude: -118.2437), counter: 20),
};
final heatmap = Heatmap(heatpoints: heatpoints);
final heatmap = Heatmap(points: heatpoints);

expect(heatmap.heatpoints, equals(heatpoints));
expect(heatmap.heatcolor, isNull);
expect(heatmap.points, equals(heatpoints));
expect(heatmap.color, isNull);
expect(heatmap.opacity, 1);
expect(heatmap.showCounter, isFalse);
expect(heatmap.counterColor, Colors.black);
});

test('Heatmap correctly assigns non-default values', () {
Expand All @@ -25,11 +27,19 @@ void main() {
interpolation: LinearInterpolation(),
densityColors: {0.0: Colors.red, 0.5: Colors.green, 1.0: Colors.blue},
);
final heatmap = Heatmap(heatpoints: heatpoints, heatcolor: heatcolor, showCounter: true);
final heatmap = Heatmap(
points: heatpoints,
color: heatcolor,
opacity: 0.5,
showCounter: true,
counterColor: Colors.white,
);

expect(heatmap.heatpoints, equals(heatpoints));
expect(heatmap.heatcolor, equals(heatcolor));
expect(heatmap.points, equals(heatpoints));
expect(heatmap.color, equals(heatcolor));
expect(heatmap.opacity, 0.5);
expect(heatmap.showCounter, isTrue);
expect(heatmap.counterColor, Colors.white);
});
});
}

0 comments on commit 92a3b9b

Please sign in to comment.