您的位置:首页 > 汽车 > 新车 > 免费的快速开发平台_最近播放中文版在线观看电视剧_测试自己适不适合做销售_市场推广计划

免费的快速开发平台_最近播放中文版在线观看电视剧_测试自己适不适合做销售_市场推广计划

2024/12/27 0:23:31 来源:https://blog.csdn.net/gaowxx/article/details/144595344  浏览:    关键词:免费的快速开发平台_最近播放中文版在线观看电视剧_测试自己适不适合做销售_市场推广计划
免费的快速开发平台_最近播放中文版在线观看电视剧_测试自己适不适合做销售_市场推广计划

需求:拓扑图中需要用动画的线条连接node,在此之前将HTML页面改成了vue页面。需要使用到G6的registerEdge 自定义边,小车的图片需要转成base64格式(并翻转),可以通过base64转image查看原来的样子。

另外,通过动态控制div的scale自适应拉伸尺寸的计算来达到自适应宽高屏幕的效果。

【完整代码】

<template><div class="body-wrap" ref="contentWrapper"><div class="graph-wrap"><div ref="graphContainer"></div></div></div>
</template><script>
import G6 from '@antv/g6';
const { getLabelPosition, transform } = G6.Util;export default {name: 'CustomEdgeGraph',data() {return {designWidth: 1920, // 设计稿宽度designHeight: 1080, // 设计稿高度currentScale: [1, 1],nodeData: {// 点集nodes: [{id: 'point1',x: 110,y: 200,},{id: 'point2',x: 110,y: 200,},{id: 'point3',x: 130,y: 630,},{id: 'point4',x: 130,y: 630,},{id: 'center',x: 500,y: 400,},{id: 'oil_star',x: 1600,y: 1030,},{id: 'oil_end',x: 100,y: 780,},{id: 'car_star',x: 1600,y: 990,},{id: 'car_end',x: 100,y: 750,},],// 边集edges: [{source: 'point1',target: 'center',curveOffset: -180,},{source: 'point2',target: 'center',curveOffset: 160,},{source: 'point3',target: 'center',curveOffset: -120,},{source: 'point4',target: 'center',curveOffset: 90,},// 动画线{source: 'point1',target: 'center',curveOffset: -180,type: 'line-growth',style: {lineAppendWidth: 5,lineWidth: 5, // 线宽stroke: 'l(0) 0:rgba(34,255,242,0.06) 0.25:rgba(34,255,242,0.5) 0.5:rgba(34,255,242,1) 0.75:rgba(34,255,242,0.5)  1:rgba(34,255,242,0.06)', // 线的颜色}},{source: 'point2',target: 'center',curveOffset: 160,type: 'line-growth',style: {lineAppendWidth: 5,lineWidth: 5, // 线宽stroke: 'l(0) 0:rgba(34,255,242,0.06) 0.25:rgba(34,255,242,0.5) 0.5:rgba(34,255,242,1) 0.75:rgba(34,255,242,0.5)  1:rgba(34,255,242,0.06)', // 线的颜色}},{source: 'point3',target: 'center',curveOffset: -120,type: 'line-growth',style: {lineAppendWidth: 5,lineWidth: 5, // 线宽stroke: 'l(0) 0:rgba(34,255,242,0.06) 0.25:rgba(34,255,242,0.5) 0.5:rgba(34,255,242,1) 0.75:rgba(34,255,242,0.5)  1:rgba(34,255,242,0.06)', // 线的颜色}},{source: 'point4',target: 'center',curveOffset: 90,type: 'line-growth',style: {lineAppendWidth: 5,lineWidth: 5, // 线宽stroke: 'l(0) 0:rgba(34,255,242,0.06) 0.25:rgba(34,255,242,0.5) 0.5:rgba(34,255,242,1) 0.75:rgba(34,255,242,0.5)  1:rgba(34,255,242,0.06)', // 线的颜色}},{source: 'oil_star',target: 'oil_end',type: 'arrow-running',style: {lineAppendWidth: 10,lineWidth: 10, // 线宽stroke: 'l(0) 0:rgba(188,133,26,0.16) 0.95:rgba(188,133,26,0.16)  1:rgba(188,133,26,0)', // 线的颜色// },// assign the control points to control the bending positions// 开车线路的中间拐点controlPoints: [{x: 600,y: 1030,},],},{source: 'car_star',target: 'car_end',type: 'car-running',style: {lineAppendWidth: 10,lineWidth: 10, // 线宽//stroke:'red'stroke: 'rgba(255,255,255,0)', // 线的颜色// },// assign the control points to control the bending positions// 开车的中间拐点controlPoints: [{x: 600,y: 990,},],},]}}},beforeDestroy() {window.removeEventListener('resize', this.onWindowResize);},mounted() {this.initGraph();this.updateScale();window.addEventListener('resize', this.updateScale);},methods: {// 自适应拉伸尺寸计算updateScale() {const { designWidth, designHeight } = this;const windowWidth = window.innerWidth;const windowHeight = window.innerHeight;// 计算宽高比const widthRatio = (windowWidth / designWidth).toFixed(4) - 0.002;const heightRatio = (windowHeight / designHeight).toFixed(4) - 0.002;const scale = [widthRatio, heightRatio];// 更新缩放比例this.currentScale = scale;this.applyTransform();},applyTransform() {const contentWrapper = this.$refs.contentWrapper;if (contentWrapper) {contentWrapper.style.transform = `scale(${this.currentScale[0]},${this.currentScale[1]})`;contentWrapper.style.transformOrigin = 'top left';}},// 自适应拉伸尺寸计算 END// 初始化图表initGraph() {const car1 = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACcAAAAeCAYAAACv1gdQAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyVpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDYuMC1jMDAyIDc5LjE2NDQ4OCwgMjAyMC8wNy8xMC0yMjowNjo1MyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIDIyLjAgKE1hY2ludG9zaCkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NUI3OUE0N0NCNjBDMTFFRjhGQUE5RDc0QzcwRDE1NkQiIHhtcE1NOkRvY3V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C+5L8VeDr83ffL49mUqamhKyReyZUQCFLDgmBoC3FQCQwwGgdgBAXDE7U88YNPs/YIbAf+LZuXvGrAE40gtAUAYAvncA2F+CjLRIfEokAP4URLcHsIWFZM3NvzOz+rTJHAegLNTUy9b3MYW8GfzDZuf47+r+5w6mo1qCf+7/ArrXCG8GGXi9AAAAOGVYSWZNTQAqAAAACAABh2kABAAAAAEAAAAaAAAAAAACoAIABAAAAAEAAAALoAMABAAAAAEAAAAMAAAAABBWpCwAAAAdSURBVCgVY/z/SOo/A5GAiUh1YGWjipFDayiGBgBcEQMSVYavwAAAAABJRU5ErkJggg=='// 自定义边类型G6.registerEdge('line-growth',{afterDraw(cfg, group) {const shape = group.get('children')[0];const length = shape.getTotalLength();shape.animate((ratio) => {// the operations in each frame. Ratio ranges from 0 to 1 indicating the prograss of the animation. Returns the modified configurationsconst startLen = ratio * length;// Calculate the lineDashconst cfg = {lineDash: [startLen, length - startLen],};return cfg;},{repeat: true, // Whether executes the animation repeatlyduration: 2000, // the duration for executing once},);},},'arc', // extend the built-in edge 'cubic' arc );G6.registerEdge("arrow-running",{afterDraw(cfg, group) {// get the first shape in the group, it is the edge's path here=const shape = group.get("children")[0];const length = shape.getTotalLength();let circleCount = Math.ceil(length / 100);circleCount = circleCount === 0 ? 1 : circleCount;const _loop = function _loop(i) {const delay = 0;const start = shape.getPoint(0);const image = group.addShape("image", {attrs: {x: start.x,y: start.y - 9,width: 14,height: 14,img: cube,}});// animation for the red circleimage.animate((ratio) => {ratio += i / circleCount;if (ratio > 1) {ratio %= 1;}const tmpPoint = shape.getPoint(ratio);const pos = getLabelPosition(shape, ratio);let matrix = [1, 0, 0, 0, 1, 0, 0, 0, 1];matrix = transform(matrix, [["t", -tmpPoint.x - 9, -tmpPoint.y],["r", pos.angle],["t", tmpPoint.x, tmpPoint.y]]);// returns the modified configurations here, x and y herereturn {x: tmpPoint.x,y: tmpPoint.y - 9,matrix};},{repeat: true, // Whether executes the animation repeatly// duration: 3000 // the duration for executing onceduration: 8 * length,easing: 'easeLinear',// delay:5 * length,});}for (let i = 0; i < circleCount; i++) {_loop(i);}}},"polyline" // extend the built-in edge 'cubic');G6.registerEdge("car-running",{afterDraw(cfg, group) {// get the first shape in the group, it is the edge's path here=const shape = group.get("children")[0];const image = group.addShape("image", {attrs: {x: 0,y: 0,width: 73,height: 41,img: car1,}});// animation for the red circleimage.animate((ratio) => {// the operations in each frame. Ratio ranges from 0 to 1 indicating the prograss of the animation. Returns the modified configurations// get the position on the edge according to the ratioconst tmpPoint = shape.getPoint(ratio);const pos = getLabelPosition(shape, ratio);let matrix = [1, 0, 0, 0, 1, 0, 0, 0, 1];// var op =1if (tmpPoint.x > 1653) {matrix = transform(matrix, [["t", -tmpPoint.x - 50, -tmpPoint.y],["r", pos.angle],["t", tmpPoint.x, tmpPoint.y]]);} else {matrix = transform(matrix, [["t", -tmpPoint.x, -tmpPoint.y + 10],["r", pos.angle],["t", tmpPoint.x, tmpPoint.y]]);}var op = 1// 当车跑到某点时变成不透明 0.5// if (tmpPoint.x > 1483) {//     op = 1// } else {//     op = 0.5// }// returns the modified configurations here, x and y herereturn {x: tmpPoint.x,y: tmpPoint.y - 36,matrix,opacity: op};},{repeat: true, // Whether executes the animation repeatlyduration: 9000 // the duration for executing once});}},"polyline" // extend the built-in edge 'cubic');this.$nextTick(() => {// 初始化图表const graph = new G6.Graph({container: this.$refs.graphContainer,width: 1920,height: 1080,modes: {default: ['drag-node', 'zoom-canvas', 'click-select']},defaultNode: { // 节点样式修改type: 'circle', // 设置节点为图片size: [0, 0], // 节点大小anchorPoints: [[0.5, 0.5],[0.5, 0.5],],},defaultEdge: { // 边通用配置type: 'arc',labelCfg: {autoRotate: true,},style: {lineAppendWidth: 3,lineWidth: 3, // 线宽stroke: 'rgba(9,237,224,0.3)', // 线的颜色},},});// 设置初始数据graph.data(this.nodeData);// 渲染图表graph.render();if (typeof window !== 'undefined')window.onresize = () => {if (!graph || graph.get('destroyed')) return;};})}}
};
</script><style lang="less" scoped>
.body-wrap {overflow: hidden;width: 1920px;height: 1080px;background: #040d27;background-size: cover;transform-origin: 0 0;
}.graph-wrap {width: 1920px;height: 1080px;background: none;
}
</style>

【小车原图示例】

【工具网站】

base64图片在线转换工具 - 站长工具

G6

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com