You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
945 B

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