feat(关系图): 优化关系图交互并增加点击高亮功能

- 增加点击表格行高亮相关节点的功能
- 优化关系图布局和样式,根据选中状态调整参数
- 为图表元素添加指针样式提升交互体验
- 清理调试用的console.log语句
- 扩展颜色数组和月份选项
This commit is contained in:
yindongqi 2025-08-11 17:44:47 +08:00
parent 34f0b3eba9
commit 1241191f38

View File

@ -485,15 +485,15 @@ const navigation = ref({
// modules使
const modules = [Autoplay, Pagination, Navigation, Scrollbar];
const prevEl = () => {
console.log("上一张");
// console.log("");
};
const nextEl = () => {
console.log("下一张");
// console.log("");
};
// swiper
const onSlideChange = (swiper: any) => {
// swiperswiperactiveIndex
console.log(swiper.activeIndex, "活动swiper更改");
// console.log(swiper.activeIndex, "swiper");
};
const swiperBoxHeight = ref("300px");
@ -555,35 +555,35 @@ const monthOptions = [
value: "5",
label: "五月",
},
// {
// value: "6",
// label: "",
// }
// ,
// {
// value: "7",
// label: "",
// },
// {
// value: "8",
// label: "",
// },
// {
// value: "9",
// label: "",
// },
// {
// value: "10",
// label: "",
// },
// {
// value: "11",
// label: "",
// },
// {
// value: "12",
// label: "",
// },
{
value: "6",
label: "六月",
}
,
{
value: "7",
label: "七月",
},
{
value: "8",
label: "八月",
},
{
value: "9",
label: "九月",
},
{
value: "10",
label: "十月",
},
{
value: "11",
label: "十一月",
},
{
value: "12",
label: "十二月",
},
];
//""
@ -664,15 +664,26 @@ const districtOptions = [
const webPageBackgroundColor = "#F0F0F0";
//
const echartsColorArray = [
"#5470c6",
"#91cc75",
"#fac858",
"#ee6666",
"#73c0de",
"#3ba272",
"#fc8452",
"#9a60b4",
"#ea7ccc",
'#5470C6',
'#91CC75',
'#FAC858',
'#EE6666',
'#73C0DE',
'#3BA272',
'#FC8452',
'#9A60B4',
'#EA7CCC',
'#27727B',
'#FE8463',
'#9BCA63',
'#FAD860',
'#F3A43B',
'#60C0DD',
'#D7504B',
'#C6E579',
'#F4E001',
'#F0805A',
'#26C0C0'
];
// const echartsColorArray = ['#FF00FF', '#00FF00'];
@ -1576,7 +1587,7 @@ const echarts2 = () => {
var svg = d3
.select(main2.value)
.append("svg")
.attr("width", windowWidth.value * 0.23)
.attr("width", windowWidth.value * 0.24)
.attr("height", (windowHeight.value - 100 - 3 * 4) / 3);
//
@ -1648,6 +1659,7 @@ const echarts2 = () => {
return echartsColorArray[randomIndex];
})
.style("opacity", 0.7)
.style("cursor", "pointer")
//
.on("mousemove", function (event, d: any) {
isTooltipVisible.value = true;
@ -1659,6 +1671,8 @@ const echarts2 = () => {
tooltip.transition().duration(200).style("opacity", 0.9);
tooltip
.html(d.data.name + "" + d.data.value)
.style("color", "gray")
.style("border", "1px solid " + echartsColorArray[Math.floor(Math.random() * echartsColorArray.length)])
.style("left", x + "px") // tooltip
.style("top", y + "px"); // tooltip
})
@ -1745,7 +1759,7 @@ const echarts2 = () => {
svg
.append("text")
.attr("class", "subtitle")
.attr("x", 5) //
.attr("x", 0) //
.attr(
"y",
((windowHeight.value - 100 - 3 * 4) / 3 - 198) / 2 + 78 + 14 * index
@ -3613,6 +3627,9 @@ const initStreetChart = () => {
//
const initRelationshipChart = () => {
if (chartRelationship) {
chartRelationship.dispose();
}
// return;
const chartDom = main9.value;
if (!chartDom) return;
@ -3620,24 +3637,60 @@ const initRelationshipChart = () => {
chartRelationship = echarts.init(chartDom);
getRelationshipNetwork().then((res) => {
let nodes;
let links;
//
const nodes = res.data.nodes.map((node: any) => ({
...node,
symbolSize: 10, //
value: 15, //
draggable: false, //
itemStyle: {
opacity: 0.8, //
},
}));
if (handleRowValue.value == "") {
// 线线
links = res.data.links.map((link: any) => ({
...link,
lineStyle: {
opacity: 0.3, // 线
},
}));
// 线线
const links = res.data.links.map((link: any) => ({
...link,
lineStyle: {
opacity: 0.3, // 线
},
}));
nodes = res.data.nodes.map((node: any) => ({
...node,
symbolSize: 10, //
value: 15, //
draggable: false, //
itemStyle: {
opacity: 0.8, //
},
}));
} else {
// 线线
links = res.data.links.filter((link: any) => link.target === handleRowValue.value || link.source === handleRowValue.value)
.map((link: any) => ({
...link,
lineStyle: {
opacity: 1, // 线
},
}))
nodes = res.data.nodes
// 线
.filter((node: any) =>
links.some(link =>
link.target === node.name || link.source === node.name
)
)
//
.map((node: any) => ({
...node,
symbolSize: 10, //
value: 15, //
draggable: false, //
itemStyle: {
opacity: 0.8, //
},
}));
}
// console.log(nodes, links, "------------");
// ECharts
const option: echarts.EChartsOption = {
@ -3660,10 +3713,10 @@ const initRelationshipChart = () => {
{
type: "graph", //
layout: "force", // 使
zoom: 0.8,
zoom: handleRowValue.value == "" ? 0.8 : 1.2,
force: {
repulsion: 1000, //
edgeLength: 1000, //
edgeLength: handleRowValue.value == "" ? 1000 : 200, //
gravity: 10, //
},
emphasis: {
@ -4279,15 +4332,19 @@ const highlightGraphNodeByName = (nodeName: string) => {
name: nodeName,
});
};
const handleRowValue = ref("");
const handleRowClick = (item: any, index: number) => {
console.log(item, index);
// console.log(item, index);
//
if (index !== 0) {
jubaoGaofaData.value.splice(index, 1); //
jubaoGaofaData.value.unshift(item); //
}
handleRowValue.value = "投诉举报-" + item.huanjie.slice(0, 2) + "-" + item.zhonglei;
console.log(handleRowValue.value);
initRelationshipChart();
};
@ -4435,6 +4492,7 @@ const handleFancyClick = (e: MouseEvent) => {
overflow: hidden;
background: rgba(0, 0, 0, 0.2);
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
cursor: pointer;
}
.scroll-item {