Skip to content

Commit

Permalink
fix: improve ebios radar for colliding points (#1403)
Browse files Browse the repository at this point in the history
* prep

* add a basic jitter function

* apply jitter to just angles for now
  • Loading branch information
ab-smith authored Jan 22, 2025
1 parent 2f1badb commit 7acf337
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions backend/ebios_rm/helpers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
from django.db.models.query import QuerySet
import math
import random


def ecosystem_radar_chart_data(stakeholders_queryset: QuerySet):
qs = stakeholders_queryset

def add_jitter(value, max_jitter=5.0):
"""Add a small random offset to prevent perfect overlaps"""
return value + random.uniform(-max_jitter, max_jitter)

def get_exposure_segment_id(value):
if value < 3:
return 1
Expand Down Expand Up @@ -39,10 +44,8 @@ def get_reliability_cluster(value):

c_data = {"clst1": [], "clst2": [], "clst3": [], "clst4": []}
r_data = {"clst1": [], "clst2": [], "clst3": [], "clst4": []}
angle_offsets = {"client": 135, "partner": 225, "supplier": 45}
angle_offset = {"client": 135, "partner": 225, "supplier": 45}

cnt_c_not_displayed = 0
cnt_r_not_displayed = 0
for sh in qs:
# current
c_reliability = sh.current_maturity * sh.current_trust
Expand All @@ -55,11 +58,11 @@ def get_reliability_cluster(value):
else 5.25
)

angle = angle_offsets[sh.category] + (
angle = angle_offset[sh.category] + (
get_exposure_segment_id(c_exposure) * (45 / 4)
)

vector = [c_criticality, angle, c_exposure_val, str(sh)]
vector = [c_criticality, add_jitter(angle, 10), c_exposure_val, str(sh)]

cluser_id = get_reliability_cluster(c_reliability)
c_data[cluser_id].append(vector)
Expand All @@ -75,11 +78,11 @@ def get_reliability_cluster(value):
else 5.25
)

angle = angle_offsets[sh.category] + (
angle = angle_offset[sh.category] + (
get_exposure_segment_id(r_exposure) * (45 / 4)
)

vector = [r_criticality, angle, r_exposure_val, str(sh)]
vector = [r_criticality, add_jitter(angle, 10), r_exposure_val, str(sh)]

cluser_id = get_reliability_cluster(r_reliability)
r_data[cluser_id].append(vector)
Expand Down

0 comments on commit 7acf337

Please sign in to comment.