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.

51 lines
1.1 KiB

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);
}
}