人物互动隐关系页面点击用户组高亮效果

This commit is contained in:
qumeng039@126.com 2025-07-30 11:23:19 +08:00
parent 841aff64da
commit c367f74182
2 changed files with 53 additions and 18 deletions

View File

@ -36,8 +36,7 @@
</template>
<script setup>
import { onMounted } from "vue"
import { provide } from "vue"
import { onMounted, ref, provide } from "vue"
import { useCharacterInteractionStore } from "@/store/llinkPrediction/index"
import UserPanel from "../components/userPanel.vue"
import PostList from "../components/postList.vue"
@ -49,10 +48,13 @@ import graphTitleImg from "@/assets/images/linkPrediction/title/graph1-title.png
import analysisTitleImg from "@/assets/images/linkPrediction/title/analysis-title.png"
const interactionStore = useCharacterInteractionStore()
//id
const userIds = ref([])
// &&
const handleSelectedUserGroup = (group) => {
interactionStore.curComponent = "detailNode"
interactionStore.curSelectedGroup = group //
userIds.value = group.list.map((user) => user.userId) //id
interactionStore.initInteractionPostList(group.relationId)
interactionStore.initGraphCommunityDetailNode(group.list.map((item) => item.groupId))
}
@ -65,6 +67,7 @@ onMounted(() => {
})
provide("communityNodeList", interactionStore.communityNodeList) //
provide("statisticsList", interactionStore.statisticsList)
provide("userIds", userIds) //ids
</script>
<style scoped lang="less">

View File

@ -40,7 +40,7 @@
</template>
<script setup>
import { defineEmits, onMounted, ref, onUnmounted, computed, watch } from "vue"
import { defineEmits, onMounted, ref, onUnmounted, computed, watch, inject, nextTick } from "vue"
import { TansTimestamp } from "@/utils/transform"
import nodeHoverImg from "@/assets/images/nodeHover.png"
import * as echarts from "echarts"
@ -49,6 +49,8 @@ import { useCharacterInteractionStore } from "@/store/llinkPrediction/index"
const interactionStore = useCharacterInteractionStore()
const { communityDetailNodeList, curSelectedGroup } = storeToRefs(interactionStore)
const emit = defineEmits(["click:goback"])
const userIds = inject("userIds", [])
const chartsData = ref({})
const handleGoback = () => {
emit("click:goback", "CommunityNode")
}
@ -62,6 +64,18 @@ watch(
{ deep: true }
)
//userids
watch(
userIds,
(newIds) => {
if (newIds.length != 0) {
nextTick(() => {
highLightUserNodes(newIds)
})
}
},
{ immediate: true }
)
//
const startTime = ref(new Date("2024-05-16 16:56:04"))
const endTime = ref(new Date("2024-05-23 10:16:56"))
@ -168,16 +182,18 @@ const initChart = async () => {
}
if (!Object.keys(interactionStore.communityDetailNodeList).length) return
Object.entries(interactionStore.communityDetailNodeList).forEach(([parentId, children]) => {
nodes.push({
id: `parent_${parentId}`,
name: parentId
})
if (!nodes.some((n) => n.id === parentId)) {
nodes.push({
id: parentId,
name: parentId
})
}
children.forEach((child) => {
if (!nodes.some((n) => n.id === child.id)) {
nodes.push(child)
}
links.push({
source: `parent_${parentId}`,
source: parentId,
target: child.id,
edge: child.isHidden ? 1 : 0,
interactionTimes: child.interactionTime,
@ -189,7 +205,7 @@ const initChart = async () => {
})
})
})
const data = { links, nodes }
chartsData.value = { links, nodes }
const categories = [
{ name: "事件活跃者", category: 0, icon: "circle" },
@ -319,7 +335,7 @@ const initChart = async () => {
},
animationDurationUpdate: 3500, //
data: data.nodes.map((node) => ({
data: chartsData.value.nodes.map((node) => ({
...node,
symbolSize: 40,
itemStyle: {
@ -341,12 +357,12 @@ const initChart = async () => {
shadowBlur: 20,
shadowColor: "#c4a651",
borderColor: "#fcd267",
borderWidth: 1,
borderWidth: 5,
borderType: "solid"
}
}
})),
links: data.links,
links: chartsData.value.links,
lineStyle: {
color: "#37ACD7",
width: 1
@ -357,14 +373,30 @@ const initChart = async () => {
chart.setOption(option)
}
const highLightUserNodes = (userIds) => {
if (!userIds) return
chart.dispatchAction({
type: "downplay",
seriesIndex: 0
})
setTimeout(() => {
//
userIds.forEach((id) => {
const index = chartsData.value.nodes.findIndex((node) => node.id === id)
if (index != -1) {
chart.dispatchAction({
type: "highlight",
dataIndex: index
})
}
})
}, 1000)
}
onMounted(() => {
initChart()
chart.on("legendselectchanged", function (params) {
//
setTimeout(() => {
chart.resize()
}, 0)
})
highLightUserNodes()
})
</script>