Skip to content

Commit

Permalink
Merge pull request #1973 from jplag/report-viwer/better-cluster-edges
Browse files Browse the repository at this point in the history
Reduce misleading of cluster edges
  • Loading branch information
tsaglam authored Sep 9, 2024
2 parents 1a1b1bb + 666f849 commit 29e90a7
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions report-viewer/src/components/ClusterGraph.vue
Original file line number Diff line number Diff line change
Expand Up @@ -165,33 +165,45 @@ const maximumSimilarity = computed(() => {
return maximumSimilarity
})
function getClampedSimilarityFromKeyIndex(firstIndex: number, secondIndex: number) {
function getClampedSimilarityFromKeyIndex(
firstIndex: number,
secondIndex: number,
min: number,
max: number
) {
const similarity = getSimilarityFromKeyIndex(firstIndex, secondIndex)
if (similarity == 0) {
return 0
}
if (minimumSimilarity.value == maximumSimilarity.value) {
if (min == max) {
return 1
}
return (
(similarity - minimumSimilarity.value) / (maximumSimilarity.value - minimumSimilarity.value)
)
return (similarity - min) / (max - min)
}
function getEdgeAlphaFromKeyIndex(firstIndex: number, secondIndex: number) {
const similarity = getSimilarityFromKeyIndex(firstIndex, secondIndex)
if (similarity == 0) {
return 1
}
return getClampedSimilarityFromKeyIndex(firstIndex, secondIndex) * 0.7 + 0.3
return (
getClampedSimilarityFromKeyIndex(
firstIndex,
secondIndex,
Math.min(minimumSimilarity.value, 0.5),
maximumSimilarity.value
) *
0.7 +
0.3
)
}
function getEdgeWidth(firstIndex: number, secondIndex: number) {
const similarity = getSimilarityFromKeyIndex(firstIndex, secondIndex)
if (similarity == 0) {
return 0.5
}
return getClampedSimilarityFromKeyIndex(firstIndex, secondIndex) * 5 + 1
return getClampedSimilarityFromKeyIndex(firstIndex, secondIndex, 0, 1) * 5 + 1
}
function getEdgeDashStyle(firstIndex: number, secondIndex: number) {
Expand Down

0 comments on commit 29e90a7

Please sign in to comment.