/
callout.js
51 lines (49 loc) · 1.18 KB
/
callout.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* Created by OXOYO on 2019/9/3.
*
* 呼喊
*/
import Global from '@antv/g6/src/global'
import Util from '@antv/g6/src/util'
import base from './base'
export default {
name: 'callout',
extendName: 'single-shape',
options: {
...base,
shapeType: 'path',
getShapeStyle (cfg) {
const size = this.getSize(cfg)
const width = size[0]
const height = size[1]
const x = 0 - width / 2
const y = 0 - height / 2
const path = [
// 左上
[ 'M', -width / 2, -height / 2 ],
// 右上
[ 'L', width / 2, -height / 2 ],
// 右下
[ 'L', width / 2, height / 4 ],
// 下拐角
[ 'L', width / 4, height / 4 ],
[ 'L', 0, height / 2 ],
[ 'L', 0, height / 4 ],
// 左下
[ 'L', -width / 2, height / 4 ],
[ 'Z' ]
]
const color = cfg.color || Global.defaultNode.color
const style = Util.mix({}, Global.defaultNode.style, {
// 节点的位置在上层确定,所以这里仅使用相对位置即可
x,
y,
width,
height,
path,
stroke: color
}, cfg.style)
return style
}
}
}