自定义交互组件
自定义渲染和自定义布局中的自定义图元,可以使用VRender提供的组件,目前支持的有以下组件:
TextAutoPoptip
TextAutoPoptip组件是VRender提供的一个交互组件,它的功能是在文本过长被省略时,hover到文本上,会自动弹出一个poptip,展示文本的全部内容。
使用TextAutoPoptip组件需要把相应的text图元配置pickable: true,开启交互,此时TextAutoPoptip组件在text图元被maxLineWidth属性省略时自动启动。如果想禁用组件保留交互,需要在text图元上配置disableAutoClipedPoptip属性为true。
TextAutoPoptip组件弹出的poptip样式,可以在theme.textPopTipStyle中配置,部分常用属性如下:
| Name | Type | Description |
|---|---|---|
| position | 'auto' | 'top' | 'tl' | 'tr' | 'bottom' | 'bl' | 'br' | 'left' | 'lt' | 'lb' | 'right' | 'rt' | 'rb' | poptip显示在相对于图元的位置 |
| title | string | string[] | number | number[] | poptip中title内容 |
| titleStyle | Partial<ITextGraphicAttribute> | poptip中title内容的样式 |
| titleFormatMethod | (t: string | string[] | number | number[]) => string | string[] | number | number[] | poptip中title内容的format方法 |
| content | string | string[] | number | number[] | poptip中content内容,默认是完整字符串 |
| contentStyle | Partial | poptip中content内容的样式 |
| contentFormatMethod | (t: string | string[] | number | number[]) => string | string[] | number | number[] | poptip中content内容的format方法 |
| space | number | title和content距离 |
| padding | Padding | poptip中的padding |
| panel | BackgroundAttributes & ISymbolGraphicAttribute & {space?:number;} | poptip中的背景样式 |
| minWidth | number | poptip中的最大宽度 |
| maxWidth | number | poptip中的最小宽度 |
| maxWidthPercent | number | poptip中的最大宽度百分比 |
| visible | boolean | poptip是否可见 |
| visibleFunc | (graphic: IGraphic) => boolean | poptip是否可见函数 |
| dx | number | poptipx方向偏移 |
| dy | number | poptipy方向偏移 |