|
@@ -1361,13 +1361,14 @@ import { svgToBase64 } from '@/utils/svgToblob'
|
|
|
},{
|
|
|
preserveDimensions:true,//让svg为实际图片大小
|
|
|
beforeSerialize:(svg)=>{
|
|
|
+ const zoom = this.graph.zoom();
|
|
|
const {x,y,width,height} = this.graph.getContentBBox(cells)
|
|
|
let {tx,ty} = this.graph.translate() // 画布偏移量
|
|
|
//给导出的svg增加一点宽高
|
|
|
- svg.setAttribute('width',width+50)
|
|
|
- svg.setAttribute('height',height+50)
|
|
|
+ svg.setAttribute('width',width+60*zoom)
|
|
|
+ svg.setAttribute('height',height+60*zoom)
|
|
|
//设置viewBox使图像居中
|
|
|
- svg.setAttribute('viewBox',`${x-25} ${y-25} ${width+50} ${height+50}`)
|
|
|
+ svg.setAttribute('viewBox',`${x-30*zoom} ${y-30*zoom} ${width+60*zoom} ${height+60*zoom}`)
|
|
|
// 在图表右下方 加上"来源:弘则研究"字样
|
|
|
let gNode = svg.getElementsByClassName('x6-graph-svg-viewport')[0]
|
|
|
// 去掉不该截图的添加图标
|
|
@@ -1384,8 +1385,8 @@ import { svgToBase64 } from '@/utils/svgToblob'
|
|
|
i--
|
|
|
}
|
|
|
let textNode = document.createElement('text')
|
|
|
- textNode.setAttribute('x',x-tx+width-90)
|
|
|
- textNode.setAttribute('y',y-ty+height+22)
|
|
|
+ textNode.setAttribute('x',(x-tx+width)/zoom-85)
|
|
|
+ textNode.setAttribute('y',(y-ty+height)/zoom+27)
|
|
|
textNode.setAttribute('font-size','16px')
|
|
|
textNode.setAttribute('font-style','italic')
|
|
|
textNode.innerText = '来源:弘则研究'
|