|
@@ -206,14 +206,15 @@ function renderTree() {
|
|
|
nodes.each(function(d) {
|
|
nodes.each(function(d) {
|
|
|
const el = d3.select(this)
|
|
const el = d3.select(this)
|
|
|
const style = getNodeStyle(d)
|
|
const style = getNodeStyle(d)
|
|
|
|
|
+ const halfSize = style.size / 2
|
|
|
|
|
|
|
|
if (style.shape === 'rect') {
|
|
if (style.shape === 'rect') {
|
|
|
el.append('rect')
|
|
el.append('rect')
|
|
|
.attr('class', 'tree-shape')
|
|
.attr('class', 'tree-shape')
|
|
|
- .attr('x', -4)
|
|
|
|
|
- .attr('y', -4)
|
|
|
|
|
- .attr('width', 8)
|
|
|
|
|
- .attr('height', 8)
|
|
|
|
|
|
|
+ .attr('x', -halfSize)
|
|
|
|
|
+ .attr('y', -halfSize)
|
|
|
|
|
+ .attr('width', style.size)
|
|
|
|
|
+ .attr('height', style.size)
|
|
|
.attr('rx', 1)
|
|
.attr('rx', 1)
|
|
|
.attr('fill', style.color)
|
|
.attr('fill', style.color)
|
|
|
.attr('stroke', 'rgba(255,255,255,0.5)')
|
|
.attr('stroke', 'rgba(255,255,255,0.5)')
|
|
@@ -221,7 +222,7 @@ function renderTree() {
|
|
|
} else {
|
|
} else {
|
|
|
el.append('circle')
|
|
el.append('circle')
|
|
|
.attr('class', 'tree-shape')
|
|
.attr('class', 'tree-shape')
|
|
|
- .attr('r', style.size / 2)
|
|
|
|
|
|
|
+ .attr('r', halfSize)
|
|
|
.attr('fill', style.color)
|
|
.attr('fill', style.color)
|
|
|
.attr('stroke', 'rgba(255,255,255,0.5)')
|
|
.attr('stroke', 'rgba(255,255,255,0.5)')
|
|
|
.attr('stroke-width', 1)
|
|
.attr('stroke-width', 1)
|
|
@@ -341,8 +342,12 @@ function renderMatchLayer(contentG, root, baseTreeHeight) {
|
|
|
.style('cursor', 'pointer')
|
|
.style('cursor', 'pointer')
|
|
|
.on('click', (e, d) => {
|
|
.on('click', (e, d) => {
|
|
|
e.stopPropagation()
|
|
e.stopPropagation()
|
|
|
- const edgeId = `${d.source}|匹配|${d.target}`
|
|
|
|
|
- store.selectEdge(edgeId)
|
|
|
|
|
|
|
+ store.selectEdge({
|
|
|
|
|
+ source: d.source,
|
|
|
|
|
+ target: d.target,
|
|
|
|
|
+ type: '匹配',
|
|
|
|
|
+ score: d.score
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
.attr('d', d => {
|
|
.attr('d', d => {
|
|
|
const midY = (d.srcY + d.tgtY) / 2
|
|
const midY = (d.srcY + d.tgtY) / 2
|
|
@@ -393,14 +398,15 @@ function renderMatchLayer(contentG, root, baseTreeHeight) {
|
|
|
matchNodes.each(function(d) {
|
|
matchNodes.each(function(d) {
|
|
|
const el = d3.select(this)
|
|
const el = d3.select(this)
|
|
|
const style = getNodeStyle(d, { isMatch: true })
|
|
const style = getNodeStyle(d, { isMatch: true })
|
|
|
|
|
+ const halfSize = style.size / 2
|
|
|
|
|
|
|
|
if (style.shape === 'rect') {
|
|
if (style.shape === 'rect') {
|
|
|
el.append('rect')
|
|
el.append('rect')
|
|
|
.attr('class', 'tree-shape')
|
|
.attr('class', 'tree-shape')
|
|
|
- .attr('x', -4)
|
|
|
|
|
- .attr('y', -4)
|
|
|
|
|
- .attr('width', 8)
|
|
|
|
|
- .attr('height', 8)
|
|
|
|
|
|
|
+ .attr('x', -halfSize)
|
|
|
|
|
+ .attr('y', -halfSize)
|
|
|
|
|
+ .attr('width', style.size)
|
|
|
|
|
+ .attr('height', style.size)
|
|
|
.attr('rx', 1)
|
|
.attr('rx', 1)
|
|
|
.attr('fill', style.color)
|
|
.attr('fill', style.color)
|
|
|
.attr('stroke', 'rgba(255,255,255,0.5)')
|
|
.attr('stroke', 'rgba(255,255,255,0.5)')
|
|
@@ -408,7 +414,7 @@ function renderMatchLayer(contentG, root, baseTreeHeight) {
|
|
|
} else {
|
|
} else {
|
|
|
el.append('circle')
|
|
el.append('circle')
|
|
|
.attr('class', 'tree-shape')
|
|
.attr('class', 'tree-shape')
|
|
|
- .attr('r', 3)
|
|
|
|
|
|
|
+ .attr('r', halfSize)
|
|
|
.attr('fill', style.color)
|
|
.attr('fill', style.color)
|
|
|
.attr('stroke', 'rgba(255,255,255,0.5)')
|
|
.attr('stroke', 'rgba(255,255,255,0.5)')
|
|
|
.attr('stroke-width', 1)
|
|
.attr('stroke-width', 1)
|
|
@@ -615,8 +621,12 @@ function renderWalkedLayer() {
|
|
|
.style('cursor', 'pointer')
|
|
.style('cursor', 'pointer')
|
|
|
.on('click', (e, d) => {
|
|
.on('click', (e, d) => {
|
|
|
e.stopPropagation()
|
|
e.stopPropagation()
|
|
|
- const edgeId = `${d.source}|${d.type}|${d.target}`
|
|
|
|
|
- store.selectEdge(edgeId)
|
|
|
|
|
|
|
+ store.selectEdge({
|
|
|
|
|
+ source: d.source,
|
|
|
|
|
+ target: d.target,
|
|
|
|
|
+ type: d.type,
|
|
|
|
|
+ score: d.score
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
.attr('d', d => {
|
|
.attr('d', d => {
|
|
|
// 同一层的边(Y坐标相近)用向下弯曲的曲线
|
|
// 同一层的边(Y坐标相近)用向下弯曲的曲线
|
|
@@ -678,17 +688,19 @@ function renderWalkedLayer() {
|
|
|
walkedNodeGroups.each(function(d) {
|
|
walkedNodeGroups.each(function(d) {
|
|
|
const el = d3.select(this)
|
|
const el = d3.select(this)
|
|
|
const style = getNodeStyle(d)
|
|
const style = getNodeStyle(d)
|
|
|
|
|
+ const halfSize = style.size / 2
|
|
|
|
|
|
|
|
if (style.shape === 'rect') {
|
|
if (style.shape === 'rect') {
|
|
|
el.append('rect')
|
|
el.append('rect')
|
|
|
.attr('class', 'walked-shape')
|
|
.attr('class', 'walked-shape')
|
|
|
- .attr('x', -4).attr('y', -4).attr('width', 8).attr('height', 8)
|
|
|
|
|
|
|
+ .attr('x', -halfSize).attr('y', -halfSize)
|
|
|
|
|
+ .attr('width', style.size).attr('height', style.size)
|
|
|
.attr('rx', 1).attr('fill', style.color)
|
|
.attr('rx', 1).attr('fill', style.color)
|
|
|
.attr('stroke', 'rgba(255,255,255,0.5)').attr('stroke-width', 1)
|
|
.attr('stroke', 'rgba(255,255,255,0.5)').attr('stroke-width', 1)
|
|
|
} else {
|
|
} else {
|
|
|
el.append('circle')
|
|
el.append('circle')
|
|
|
.attr('class', 'walked-shape')
|
|
.attr('class', 'walked-shape')
|
|
|
- .attr('r', 3).attr('fill', style.color)
|
|
|
|
|
|
|
+ .attr('r', halfSize).attr('fill', style.color)
|
|
|
.attr('stroke', 'rgba(255,255,255,0.5)').attr('stroke-width', 1)
|
|
.attr('stroke', 'rgba(255,255,255,0.5)').attr('stroke-width', 1)
|
|
|
}
|
|
}
|
|
|
|
|
|