mirror of
https://github.com/bellingcat/ukraine-timemap.git
synced 2026-06-12 21:38:35 +03:00
Created utility function isIdentical; moved DefsClusters into Clusters file
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import moment from 'moment'
|
||||
import hash from 'object-hash'
|
||||
|
||||
|
||||
let { DATE_FMT, TIME_FMT } = process.env
|
||||
if (!DATE_FMT) DATE_FMT = 'MM/DD/YYYY'
|
||||
@@ -159,6 +161,10 @@ export function selectTypeFromPathWithPoster (path, poster) {
|
||||
return { type: typeForPath(path), path, poster }
|
||||
}
|
||||
|
||||
export function isIdentical (obj1, obj2) {
|
||||
return hash(obj1) === hash(obj2)
|
||||
}
|
||||
|
||||
export function calcOpacity (num) {
|
||||
/* Events have opacity 0.5 by default, and get added to according to how many
|
||||
* other events there are in the same render. The idea here is that the
|
||||
@@ -169,10 +175,16 @@ export function calcOpacity (num) {
|
||||
}
|
||||
|
||||
export function calcClusterOpacity (pointCount, totalPoints) {
|
||||
/* Clusters represent multiple events within a specific radius. The darker the cluster,
|
||||
the larger the number of underlying events. We use a multiplication factor (50) here as well
|
||||
to ensure that the larger clusters have an appropriately darker shading. */
|
||||
return Math.min(0.85, 0.08 + (pointCount / totalPoints) * 50)
|
||||
}
|
||||
|
||||
export function calcClusterSize (pointCount, totalPoints) {
|
||||
/* The larger the cluster size, the higher the count of points that the cluster represents.
|
||||
Just like with opacity, we use a multiplication factor to ensure that clusters with higher point
|
||||
counts appear larger. */
|
||||
return Math.min(50, 10 + (pointCount / totalPoints) * 150)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user