Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPC-9946: Use tab specific radius factors please #1238

Merged
merged 4 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions html/modules/custom/ghi_blocks/js/map/map.circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
continue;
}
let location_data = Drupal.hpc_map.getLocationDataById(state, object_id);
let radius = Drupal.hpc_map.getRadius(location_data, scale, base_radius/scale);
let radius = Drupal.hpc_map.getRadius(state, location_data, scale, base_radius/scale);
offset += radius + (base_radius + 3)/scale;
}
return offset;
Expand Down Expand Up @@ -168,7 +168,7 @@
.transition()
.duration(250)
.attr('fill', d => Drupal.hpc_map_circle.getColor(d, map_state, map_id))
.attr('r', d => Drupal.hpc_map.getRadius(d, scale, radius) + base_radius/scale)
.attr('r', d => Drupal.hpc_map.getRadius(map_state, d, scale, radius) + base_radius/scale)
.attr('opacity', d => Drupal.hpc_map_circle.getOpacity(d, map_state, map_id));
}
else {
Expand All @@ -188,7 +188,7 @@
.attr('cursor', attrs.cursor)
.attr('opacity', d => Drupal.hpc_map_circle.getOpacity(d, map_state, map_id))
.attr('fill', d => Drupal.hpc_map_circle.getColor(d, map_state, map_id))
.attr('r', d => Drupal.hpc_map.getRadius(d, scale, radius));
.attr('r', d => Drupal.hpc_map.getRadius(map_state, d, scale, radius));
}
}

Expand Down Expand Up @@ -249,7 +249,7 @@
.duration(500)
.attr('cursor', attrs.cursor)
.attr('fill', d => Drupal.hpc_map_circle.getColor(d, state, map_id))
.attr('r', d => Drupal.hpc_map.getRadius(d, scale, radius))
.attr('r', d => Drupal.hpc_map.getRadius(state, d, scale, radius))
.attr('stroke-width', strokeWidth)
.attr('opacity', d => Drupal.hpc_map_circle.getOpacity(d, state, map_id));
},
Expand All @@ -260,7 +260,7 @@
.attr('stroke', attrs.stroke)
.attr('cursor', attrs.cursor)
.attr('fill', d => Drupal.hpc_map_circle.getColor(d, state, map_id))
.attr('r', d => Drupal.hpc_map.getRadius(d, scale, radius))
.attr('r', d => Drupal.hpc_map.getRadius(state, d, scale, radius))
.attr('stroke-width', strokeWidth)
.attr('opacity', d => Drupal.hpc_map_circle.getOpacity(d, state, map_id));
},
Expand Down
2 changes: 1 addition & 1 deletion html/modules/custom/ghi_blocks/js/map/map.donut.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
let group_keys = Object.keys(object[state.index]);
let primary_key = group_keys[0];

let r = object[state.index][primary_key] > 0 ? Drupal.hpc_map.getRadius(object, 1, base_radius, object.radius_factor / scale, min_radius / Math.sqrt(scale)) : min_radius;
let r = object[state.index][primary_key] > 0 ? Drupal.hpc_map.getRadius(state, object, 1, base_radius, object.radius_factor / scale, min_radius / Math.sqrt(scale)) : min_radius;
let x = proj.latLngToLayerPoint(object.latLng).x;
let y = proj.latLngToLayerPoint(object.latLng).y;

Expand Down
14 changes: 6 additions & 8 deletions html/modules/custom/ghi_blocks/js/map/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -807,11 +807,6 @@
if (focus_state) {
Drupal.hpc_map.moveLocationToFront(contained_element);
}
// else if (state.active_location) {
// let active_element = Drupal.hpc_map.getElementFromDataObject(state.active_location, state);
// Drupal.hpc_map.moveLocationToFront(active_element);
// }

}

// Change the admin level.
Expand Down Expand Up @@ -893,24 +888,27 @@
}

// Get the factor for the radius.
Drupal.hpc_map.getRadiusFactor = function(d) {
Drupal.hpc_map.getRadiusFactor = function(d, state) {
if (typeof d == 'undefined') {
return 1;
}
if (typeof d.radius_factor_grouped != 'undefined') {
return d.radius_factor_grouped;
}
if (typeof d.radius_factors != 'undefined' && typeof d.radius_factors[state.index] != 'undefined') {
return d.radius_factors[state.index];
}
if (typeof d.radius_factor != 'undefined') {
return d.radius_factor;
}
return 1;
}

// Calculate the radius for the given data point.
Drupal.hpc_map.getRadius = function(d, scale, base_radius, radius_factor, min_radius) {
Drupal.hpc_map.getRadius = function(state, d, scale, base_radius, radius_factor, min_radius) {
var admin_level = typeof d.admin_level != 'undefined' ? d.admin_level : 1;
if (typeof radius_factor == 'undefined') {
radius_factor = Drupal.hpc_map.getRadiusFactor(d);
radius_factor = Drupal.hpc_map.getRadiusFactor(d, state);
}
let radius = (base_radius + (radius_factor / scale)) / admin_level;
return (typeof min_radius != 'undefined') ? (radius > min_radius ? radius : min_radius) : radius;
Expand Down
Loading