Commit 8067f8f4 authored by 郭铭瑶's avatar 郭铭瑶 🤘

优化

parent 4d35e7f3
...@@ -687,44 +687,51 @@ export default class RelationGraph { ...@@ -687,44 +687,51 @@ export default class RelationGraph {
}) // x 坐标为两点中心距离减去自身长度一半 }) // x 坐标为两点中心距离减去自身长度一半
// 5.修改节点的位置 // 5.修改节点的位置
this.circles.attr('cx', (d) => d.x).attr('cy', (d) => d.y)
this.squares
.attr('x', (d) => d.x - r)
.attr('y', (d) => d.y - r)
.attr('points', (d) => polygonPoints(d.x, d.y, r, 6))
this.pentagons
.attr('x', (d) => d.x - r)
.attr('y', (d) => d.y - r)
.attr('points', (d) => polygonPoints(d.x, d.y, r, 10))
// 让menu随圆圈移动 // 让menu随圆圈移动
this.circles.each(function () { if (this.circles) {
const menuEle = d3.select(this.nextSibling) this.circles.attr('cx', (d) => d.x).attr('cy', (d) => d.y)
if (!menuEle.empty()) { this.circles.each(function () {
const self = d3.select(this) const menuEle = d3.select(this.nextSibling)
const cx = self.attr('cx') if (!menuEle.empty()) {
const cy = self.attr('cy') const self = d3.select(this)
menuEle.attr('transform', `translate(${cx},${cy})`).raise() const cx = self.attr('cx')
} const cy = self.attr('cy')
}) menuEle.attr('transform', `translate(${cx},${cy})`).raise()
this.squares.each(function () { }
const menuEle = d3.select(this.nextSibling) })
if (!menuEle.empty()) { }
const self = d3.select(this) if (this.squares) {
const cx = +self.attr('x') + r this.squares
const cy = +self.attr('y') + r .attr('x', (d) => d.x - r)
menuEle.attr('transform', `translate(${cx},${cy})`).raise() .attr('y', (d) => d.y - r)
} .attr('points', (d) => polygonPoints(d.x, d.y, r, 6))
})
this.pentagons.each(function () { this.squares.each(function () {
const menuEle = d3.select(this.nextSibling) const menuEle = d3.select(this.nextSibling)
if (!menuEle.empty()) { if (!menuEle.empty()) {
const self = d3.select(this) const self = d3.select(this)
const cx = +self.attr('x') + r const cx = +self.attr('x') + r
const cy = +self.attr('y') + r const cy = +self.attr('y') + r
menuEle.attr('transform', `translate(${cx},${cy})`).raise() menuEle.attr('transform', `translate(${cx},${cy})`).raise()
} }
}) })
}
if (this.pentagons) {
this.pentagons
.attr('x', (d) => d.x - r)
.attr('y', (d) => d.y - r)
.attr('points', (d) => polygonPoints(d.x, d.y, r, 10))
this.pentagons.each(function () {
const menuEle = d3.select(this.nextSibling)
if (!menuEle.empty()) {
const self = d3.select(this)
const cx = +self.attr('x') + r
const cy = +self.attr('y') + r
menuEle.attr('transform', `translate(${cx},${cy})`).raise()
}
})
}
} }
// 高亮元素及其相关的元素 // 高亮元素及其相关的元素
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment