|
|
|
import { Graph, register, Rect, ExtensionCategory } from '@antv/g6';
|
|
|
|
import { NODE_SIZE } from "./index";
|
|
|
|
|
|
|
|
export default class UserCardNode extends Rect {
|
|
|
|
get nodeData() {
|
|
|
|
return this.context.graph.getNodeData(this.id);
|
|
|
|
}
|
|
|
|
|
|
|
|
get data() {
|
|
|
|
return this.nodeData.data || {};
|
|
|
|
}
|
|
|
|
|
|
|
|
// 用户名样式
|
|
|
|
|
|
|
|
|
|
|
|
drawNameShape(attributes: any, container: any) {
|
|
|
|
if (!attributes.customData.name) return;
|
|
|
|
|
|
|
|
const getUsernameStyle = (attributes: any) => {
|
|
|
|
return {
|
|
|
|
// x: -20,
|
|
|
|
text: this.data.name || '',
|
|
|
|
fontSize: 12,
|
|
|
|
fill: '#262626',
|
|
|
|
fontWeight: 'bold',
|
|
|
|
textAlign: 'center',
|
|
|
|
textBaseline: 'middle',
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
const usernameStyle = getUsernameStyle(attributes);
|
|
|
|
this.upsert('username', 'text', usernameStyle, container);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
drawTypeShape(attributes: any, container: any) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
render(attributes: any, container: any) {
|
|
|
|
// 渲染基础矩形
|
|
|
|
super.render(attributes, container);
|
|
|
|
|
|
|
|
this.drawTypeShape(attributes, container);
|
|
|
|
this.drawNameShape(attributes, container);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|