|
|
|
|
@ -400,7 +400,7 @@ function getData1() {
|
|
|
|
|
groupId: groupId1.value, |
|
|
|
|
type: type1.value |
|
|
|
|
}).then(data => { |
|
|
|
|
list1.value = data |
|
|
|
|
list1.value = withRankColors(data) |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -411,7 +411,7 @@ function getData2() {
|
|
|
|
|
groupId: groupId2.value, |
|
|
|
|
type: type2.value |
|
|
|
|
}).then(data => { |
|
|
|
|
list2.value = data |
|
|
|
|
list2.value = withRankColors(data) |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -422,10 +422,23 @@ function getData3() {
|
|
|
|
|
groupId: groupId3.value, |
|
|
|
|
type: type3.value |
|
|
|
|
}).then(data => { |
|
|
|
|
list3.value = data |
|
|
|
|
list3.value = withRankColors(data) |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function withRankColors(data) { |
|
|
|
|
const rankedItems = data.map((item, index) => ({ item, index })) |
|
|
|
|
.sort((a, b) => Number(b.item.value) - Number(a.item.value) || a.index - b.index); |
|
|
|
|
const redCount = Math.ceil(data.length / 3); |
|
|
|
|
const yellowCount = Math.ceil((data.length - redCount) / 2); |
|
|
|
|
const barColors = []; |
|
|
|
|
rankedItems.forEach(({ index }, rank) => { |
|
|
|
|
const colorIndex = rank < redCount ? 0 : rank < redCount + yellowCount ? 1 : 2; |
|
|
|
|
barColors[index] = colors[colorIndex].color; |
|
|
|
|
}); |
|
|
|
|
return data.map((item, index) => ({ ...item, barColor: barColors[index] })); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function withProfileScope(data, query, category) { |
|
|
|
|
return data.map(item => ({ |
|
|
|
|
...item, |
|
|
|
|
@ -444,7 +457,7 @@ function getData4() {
|
|
|
|
|
groupId: groupId4.value |
|
|
|
|
}; |
|
|
|
|
leadNegative(query).then(data => { |
|
|
|
|
list4.value = withProfileScope(data, query, 'lead'); |
|
|
|
|
list4.value = withRankColors(withProfileScope(data, query, 'lead')); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -455,7 +468,7 @@ function getData5() {
|
|
|
|
|
groupId: groupId5.value |
|
|
|
|
}; |
|
|
|
|
policeNegative(query).then(data => { |
|
|
|
|
list5.value = withProfileScope(data, query, 'police'); |
|
|
|
|
list5.value = withRankColors(withProfileScope(data, query, 'police')); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -466,7 +479,7 @@ function getData6() {
|
|
|
|
|
groupId: groupId6.value |
|
|
|
|
}; |
|
|
|
|
auxNegative(query).then(data => { |
|
|
|
|
list6.value = withProfileScope(data, query, 'aux'); |
|
|
|
|
list6.value = withRankColors(withProfileScope(data, query, 'aux')); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|