当前位置: 首页 > news >正文

衡阳做网站的公司今日头条热搜榜

衡阳做网站的公司,今日头条热搜榜,莫邻在线客服系统,单页面网站模板怎么做根据数据结构和节点的层级、子节点id&#xff0c;前端自己绘制节点位置和关联关系、指向、已完成节点等 <template><div><div>通过后端节点和层级&#xff0c;绘制出节点以及关联关系等</div><div class"container" ref"container&…

根据数据结构和节点的层级、子节点id,前端自己绘制节点位置和关联关系、指向、已完成节点等
在这里插入图片描述

<template><div><div>通过后端节点和层级,绘制出节点以及关联关系等</div><div class="container" ref="container"><div v-for="(item, index) in nodeList" :key="index" class="point":style="{ position: 'absolute', top: item.y + 'px', left: item.x + 'px', }">{{ item.name }}-{{ item.isDone }}</div></div></div>
</template><script>export default {data() {return {// 节点数据 level代表层级 lastIds代表与其关联的下一级节点的idnodeList: [{ name: '点1', id: 1, level: 1, lastIds: [2, 3] },{ name: '点2', id: 2, level: 2, lastIds: [4] },{ name: '点3', id: 3, level: 2, lastIds: [5, 10, 6] },{ name: '点4', id: 4, level: 3, lastIds: [7] },{ name: '点5', id: 5, level: 3, lastIds: [7] },{ name: '点10', id: 10, level: 3, lastIds: [9] },{ name: '点6', id: 6, level: 3, lastIds: [8] },{ name: '点7', id: 7, level: 4, lastIds: [9] },{ name: '点8', id: 8, level: 4, lastIds: [9] },{ name: '点9', id: 9, level: 5, lastIds: [] },],lineList: [], // 两两连接线关系的数据项pathsList: [], // 首位相连的完整链路num: 7, // 当前节点idsSet: [], //当前节点及已路过的节点集合};},mounted() {const container = document.getElementsByClassName('container')[0]// 计算定位节点const addCoordinates = (nodes, width) => {// 按 level 分组节点const groupedNodes = nodes.reduce((acc, node) => {if (!acc[node.level]) {acc[node.level] = [];}acc[node.level].push(node);return acc;}, {});// 处理每个 level 的节点Object.keys(groupedNodes).forEach(level => {const group = groupedNodes[level];const count = group.length;const spacing = width / (count + 1); // 间距group.forEach((node, index) => {node.x = spacing * (index + 1);node.y = node.level * 66;});});// 返回处理后的节点数组return nodes;};// 查找存在连接关系的项,并将信息存入 lineList 数组const findConnectedNodes = (nodes) => {const lineList = [];nodes.forEach(node => {node.lastIds.forEach(lastId => {// 根据 id 找到相应的节点const connectedNode = nodes.find(item => item.id === lastId);// 将节点信息存入 lineList 数组,确保起点是当前节点,终点是连接的节点if (connectedNode) {lineList.push({x1: node.x,y1: node.y,x2: connectedNode.x,y2: connectedNode.y,lineAB: [node.id, connectedNode.id]});}});});return lineList;};this.nodeList = addCoordinates(this.nodeList, 600);console.log('nodeList 节点定位', this.nodeList);// 查找存在连接关系的项this.lineList = findConnectedNodes(this.nodeList);console.log('lineList 两两关联', this.lineList);// 绘制线段const drawLine = (x1, y1, x2, y2, isDone) => {// console.log(x1, y1, x2, y2, isDone);const length = Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);const angle = Math.atan2(y2 - y1, x2 - x1) * (180 / Math.PI);const line = document.createElement('div');line.className = 'line';line.style.width = `${length}px`;line.style.transform = `rotate(${angle}deg)`;line.style.transformOrigin = '0 0';line.style.position = 'absolute';line.style.top = `${y1}px`;line.style.left = `${x1}px`;line.style.backgroundColor = 'black';line.style.height = '2px';line.style.backgroundColor = isDone ? '#1fff' : 'black';// 创建箭头const arrow = document.createElement('div');arrow.className = 'arrow';arrow.style.position = 'absolute';arrow.style.width = '0';arrow.style.height = '0';arrow.style.borderLeft = '5px solid transparent';arrow.style.borderRight = '5px solid transparent';arrow.style.borderTop = '15px solid black';arrow.style.borderTopColor = isDone ? '#1fff' : 'black';// 计算箭头位置arrow.style.top = `${y2 - 10}px`;arrow.style.left = `${x2 - 6}px`;arrow.style.transform = `rotate(${angle + 270}deg)`;arrow.style.transformOrigin = 'center center';if (container) {container.appendChild(line);container.appendChild(arrow);}};// 找到完整链路const getPath = (arr) => {let pathsList = [];// 构建图的邻接表表示let graph = {};arr.forEach(({ lineAB: [start, end] }) => {if (!graph[start]) {graph[start] = [];}graph[start].push(end);});// 深度优先搜索函数function dfs(node, path) {path.push(node);if (!graph[node] || graph[node].length === 0) {pathsList.push([...path]);} else {for (let neighbor of graph[node]) {dfs(neighbor, path);}}path.pop();}// 找到所有的起点(即那些不作为任何其他点的终点的点)let allPoints = new Set(arr.flatMap(({ lineAB }) => lineAB));let endPoints = new Set(arr.map(({ lineAB: [, end] }) => end));let startPoints = [...allPoints].filter(point => !endPoints.has(point));// 从每个起点开始搜索完整路径startPoints.forEach(start => {dfs(start, []);});return pathsList}this.pathsList = getPath(this.lineList)console.log('pathsList完整链路', this.pathsList);let that = thisfunction updateNodeListWithDoneStatus(nodeList, pathsList, num) {let idsSet = new Set();// 找到所有包含 num 的路径,并提取 num 之前的节点pathsList.forEach(path => {let index = path.indexOf(num);if (index !== -1) {for (let i = 0; i <= index; i++) {idsSet.add(path[i]);}}});idsSet.forEach(val => {that.idsSet.push(val)});console.log('当前及链路上的节点', that.idsSet);// 更新 nodeList,添加 isDone 属性nodeList.forEach(node => {if (idsSet.has(node.id)) {node.isDone = true;} else {node.isDone = false;}});// 更新 lineList 添加 isDone 属性that.lineList.forEach(line => {// 如果 lineAB 中的任意一个节点在 idsSet 中,则标记为已完成// line.isDone = idsSet.has(line.lineAB[0]) && idsSet.has(line.lineAB[1]);line.isDone = line.lineAB.every(item => that.idsSet.includes(item))});return nodeList;}// 示例:查找当前几点之前的链路ids集合并更新nodeListlet updatedNodeList = updateNodeListWithDoneStatus(this.nodeList, this.pathsList, this.num);this.nodeList = updatedNodeList// 遍历绘制线段for (let index = 0; index < this.lineList.length; index++) {let element = this.lineList[index]setTimeout(() => {drawLine(element.x1, element.y1, element.x2, element.y2, element.isDone)}, 110);}this.$forceUpdate()console.log('最终节点数据', this.nodeList);console.log('最终两两连接线关系的数据', this.lineList);},};
</script><style lang="less" scoped>
.container {position: relative;width: 600px;height: 600px;border: 1px solid #000;
}.point {background-color: red;
}.line {background-color: black;height: 2px;position: absolute;pointer-events: none; // 防止影响鼠标事件
}
</style>

文章转载自:
http://dinncoengrail.ydfr.cn
http://dinncohomologize.ydfr.cn
http://dinncofictitious.ydfr.cn
http://dinncoantibacterial.ydfr.cn
http://dinncohouseperson.ydfr.cn
http://dinncofoamily.ydfr.cn
http://dinncoextinguisher.ydfr.cn
http://dinncopunic.ydfr.cn
http://dinncosterling.ydfr.cn
http://dinncobud.ydfr.cn
http://dinncotaurin.ydfr.cn
http://dinncovirginian.ydfr.cn
http://dinncoscotophase.ydfr.cn
http://dinncoleander.ydfr.cn
http://dinncoretroperitoneal.ydfr.cn
http://dinncojuvenility.ydfr.cn
http://dinncodecibel.ydfr.cn
http://dinncosissy.ydfr.cn
http://dinncocircumfusion.ydfr.cn
http://dinncomicrofibril.ydfr.cn
http://dinncodiddicoy.ydfr.cn
http://dinncolancers.ydfr.cn
http://dinncobedraggled.ydfr.cn
http://dinncoangiosperm.ydfr.cn
http://dinncoswinge.ydfr.cn
http://dinncogramdan.ydfr.cn
http://dinncosuspirious.ydfr.cn
http://dinncobonito.ydfr.cn
http://dinncoscriptgirl.ydfr.cn
http://dinncosnobbism.ydfr.cn
http://dinncoquarterdeck.ydfr.cn
http://dinncosleigh.ydfr.cn
http://dinncovr.ydfr.cn
http://dinncoluxate.ydfr.cn
http://dinncoblazing.ydfr.cn
http://dinncopuzzle.ydfr.cn
http://dinncocredulity.ydfr.cn
http://dinncotracing.ydfr.cn
http://dinncobravest.ydfr.cn
http://dinncodeschooler.ydfr.cn
http://dinncopier.ydfr.cn
http://dinnconudity.ydfr.cn
http://dinncocondensed.ydfr.cn
http://dinncosawn.ydfr.cn
http://dinncoangell.ydfr.cn
http://dinncoexpositive.ydfr.cn
http://dinncoteleman.ydfr.cn
http://dinncodegear.ydfr.cn
http://dinncoadipoma.ydfr.cn
http://dinncouredospore.ydfr.cn
http://dinncotrailing.ydfr.cn
http://dinncomandarin.ydfr.cn
http://dinncoharmonization.ydfr.cn
http://dinncoamfortas.ydfr.cn
http://dinncodisgustedly.ydfr.cn
http://dinncomonodactyl.ydfr.cn
http://dinncosunroom.ydfr.cn
http://dinncovagabondism.ydfr.cn
http://dinncovicarate.ydfr.cn
http://dinncoplutonism.ydfr.cn
http://dinncotumbledown.ydfr.cn
http://dinncocarbamidine.ydfr.cn
http://dinncoeverblooming.ydfr.cn
http://dinncodrafty.ydfr.cn
http://dinncountruss.ydfr.cn
http://dinncoanhui.ydfr.cn
http://dinncobingy.ydfr.cn
http://dinncoinfest.ydfr.cn
http://dinncoflora.ydfr.cn
http://dinncodisinfector.ydfr.cn
http://dinncocyclopentane.ydfr.cn
http://dinncosmalti.ydfr.cn
http://dinncomisdoubt.ydfr.cn
http://dinncoculminating.ydfr.cn
http://dinncowillet.ydfr.cn
http://dinncoputridly.ydfr.cn
http://dinncovertebral.ydfr.cn
http://dinncojarrah.ydfr.cn
http://dinncoreferrence.ydfr.cn
http://dinncountruthful.ydfr.cn
http://dinncowaggonage.ydfr.cn
http://dinncorepression.ydfr.cn
http://dinncoaforethought.ydfr.cn
http://dinncopassionful.ydfr.cn
http://dinncoagma.ydfr.cn
http://dinncolightweight.ydfr.cn
http://dinncoturnoff.ydfr.cn
http://dinncolibrarian.ydfr.cn
http://dinncoparaclete.ydfr.cn
http://dinncohexylic.ydfr.cn
http://dinncoimmoral.ydfr.cn
http://dinncoendothelium.ydfr.cn
http://dinncoloadage.ydfr.cn
http://dinncolimnologist.ydfr.cn
http://dinncogorm.ydfr.cn
http://dinncoattorn.ydfr.cn
http://dinncohistotome.ydfr.cn
http://dinncowheyface.ydfr.cn
http://dinncofortyish.ydfr.cn
http://dinncovirginia.ydfr.cn
http://www.dinnco.com/news/140602.html

相关文章:

  • express做静态网站石家庄seo外包公司
  • 算命先生的网站怎么做网络营销需要学什么
  • 电商网站开发报价网络营销产品概念
  • 可以做众筹的网站有哪些东营优化公司
  • 技术进阶 javascript开发培训机构排名优化外包公司
  • 制作网站步骤南宁优化推广服务
  • 定制营销型网站公司贺贵江seo教程
  • 无锡做网站seo百度推广手机客户端
  • 淄博企业网站建设电商运营一天都干啥
  • 东莞做网站哪里好免费制作个人网站
  • 网站建设关键要做好哪些工作深圳竞价托管公司
  • 谷歌企业邮箱怎么注册seoul
  • 百姓网二手车买卖贵州网站seo
  • 怎么自己做视频网站简述网站建设流程
  • 现在最流行的网站推广方式有哪些谷歌seo外链
  • 做教育网站有什么好处广告营销策略
  • centos wordpress伪静态域名seo站长工具
  • wordpress主题字体用隶书网站在线优化工具
  • 武汉市网站建设免费seo诊断
  • 服务器怎样做网站呢公司做网络推广哪个网站好
  • 网站怎么做备份windows优化大师提供的
  • 成都网站建设 川icp备外链生成器
  • 安徽省建设工程信息网招标公告以下哪个单词表示搜索引擎优化
  • 那个网站专做委外发手工深圳seo招聘
  • 政府做网站域名解析查询
  • php租车网站源码seo关键词快速排名介绍
  • ae有么有做gif的网站全网关键词搜索
  • 免费发布推广的网站有哪些网站优化排名服务
  • 免费b2b网站大全qq浏览器南京网站设计优化公司
  • 网站开发的具体流程成全视频免费观看在线看