import { jsx, Component, computeLayout } from '@antv/f-engine'; import { GuideProps } from '../withGuide'; export interface TagGuideProps extends GuideProps { points?: { x: number; y: number }[] | null; canvasWidth?: number; canvasHeight?: number; offsetX?: number | string; offsetY?: number | string; autoAdjust?: boolean; /** * 箭头的方向 */ direct?: string; /** * 箭头的边长 */ side?: string | number; /** * 文字内容 */ content?: string; /** * 背景样式设置,见 group 绘图属性 */ background?: any; /** * 文字样式 */ textStyle?: any; } const defaultProps: Omit = { offsetX: 0, offsetY: 0, points: [], direct: 'tl', side: '8px', autoAdjust: true, }; const defaultStyle = { container: { fill: '#1677FF', radius: '4px', padding: ['4px', '8px'], }, text: { fontSize: '22px', fill: '#fff', }, arrow: { fill: '#1677FF', }, }; const Label = ({ content, background, textStyle, animation = {} }) => { return ( ); }; export default class Tag extends Component { render() { const { props, context } = this; const { px2hd } = context; const cfg = { ...defaultProps, ...props }; const { points, content, offsetX, offsetY, direct, side, autoAdjust, canvasWidth, canvasHeight, background, textStyle, animation, } = px2hd(cfg); const { x, y } = points[0] || {}; if (isNaN(x) || isNaN(y)) return null; const offsetXNum = context.px2hd(offsetX); const offsetYNum = context.px2hd(offsetY); let posX = x + (offsetXNum || 0); let posY = y + (offsetYNum || 0); const { layout } = computeLayout( this,