It is not only a fully functional graph visualization library, but also an explorer of data relationships.
!!!###!!!title=Extensions and Plugins——VisActor/VRender tutorial documents!!!###!!!!!!###!!!description=VRender supports the registration of extensions and plugins, and some built-in functions are supported by extensions and plugins. The following examples show how to write extensions and plugins.!!!###!!!
Extensions and Plugins
VRender supports the registration of extensions and plugins, and some built-in functions are supported by extensions and plugins. The following examples show how to write extensions and plugins.
Custom Rendering Extension
Users can write their own rendering extensions to achieve the desired effects. If we want to replace the existing rect rendering with a hand-drawn style rendering, we need to:
Write the RoughCanvasRectRender class, which implements the IGraphicRender interface
Register your class in a runtime contribution module
import { DefaultCanvasRectRender, GraphicRender } from '@visactor/vrender';
export const yourModule = ({ bind }) => {
// rect
bind(RoughCanvasRectRender)
.toDynamicValue(({ container }) => new RoughCanvasRectRender(container.getAll(DefaultCanvasRectRender)[0]))
.inSingletonScope(); bind(GraphicRender).toService(RoughCanvasRectRender);};
Before creating the App, install your module through the runtime contribution installer
import { installRuntimeContributionModule } from '@visactor/vrender/entries/runtime-contribution';installRuntimeContributionModule(yourModule, {
targets: ['graphic-renderer']
});
If the App already exists, pass it explicitly: installRuntimeContributionModule(yourModule, { app, targets: ['graphic-renderer'] }).
Custom Modification of Render Flow Injection
If you don't want to modify the entire rendering logic but just want to do some operations before and after rendering, such as drawing the background before rect rendering, the process is as follows:
Write a contribution, which implements the IBaseRenderContribution interface
Register your class in a runtime contribution module
import { RectRenderContribution } from '@visactor/vrender';
export const yourModule = ({ bind }) => {
// rect
bind(RectBackgroundRenderContribution).toSelf().inSingletonScope(); bind(RectRenderContribution).toService(RectBackgroundRenderContribution);};
Before creating the App, install your module through the runtime contribution installer
import { installRuntimeContributionModule } from '@visactor/vrender/entries/runtime-contribution';installRuntimeContributionModule(yourModule, {
targets: ['graphic-renderer']
});
If the App already exists, pass it explicitly: installRuntimeContributionModule(yourModule, { app, targets: ['graphic-renderer'] }).
Developing Plugins
Sometimes we only need to use some hooks to develop the desired plugins. For example, if you want to do automatic rendering, the plugin should be developed as follows: