拓展 / PivotickPlugin
接口: PivotickPlugin
Pivotick 插件:一个独立的 UI 元素、键绑定和生命周期挂钩包,可以将自身安装到图表中,而核心不需要知道它的存在。
通过 GraphOptions.plugins 声明式注册,或通过 Graph.use 命令式注册:
ts
const minimap: PivotickPlugin = {
name: 'minimap',
install(ctx) {
ctx.addElement(new MinimapPanel(ctx.ui), ctx.layout?.canvas)
ctx.addKeybinding({ key: 'm', callback: () => ... })
},
}
new Graph(el, data, { plugins: [minimap] })
// or
graph.use(minimap)方法
install()
install(
ctx):void
安装插件时调用一次。
参数
ctx
返回值
void
属性
name
name:
string
稳定标识符,用于日志记录和重复数据删除。