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

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

View File

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