Skip to main content

Active Filtering

Filter drag targets as your users start to drag new connections using the ActiveFiltering plugin.
Vanilla JS
React
Angular
Vue
Svelte
Typescript
JsPlumb, leading alternative to GoJS, JointJS and ReactFlow

The source code for this demo is available on Github.

Vanilla JS
Angular
React
Svelte
https://github.com/jsplumb-demonstrations/active-filtering

If you haven't got a license for JsPlumb, we offer 30 day evaluations.

Start a free trial
Active Filtering
What is active filtering?

Active filtering provides a way to filter connection targets when a drag begins. Try dragging a connection from one node to another - when you start to drag, the available targets are filtered.

How is it configured?

Active filtering is configured via a plugin for the Surface component. When an activeFiltering plugin is set on a Surface and a beforeConnect function is supplied to the Toolkit's constructor, that function is called before a new connection is dragged, for every possible target for the current source. Whenever the beforeConnect method returns false, the corresponding target object (a node, group or port) is disabled, and the user will not be able to drop the connection onto it.

In this demonstration, each node contains a set of entries which each contain the name of two types of animal. Entries are deemed connectable if one or more animals from the source entry are matched in a given target. Disabled vertices have a data-jtk-enabledattribute written onto them with a value of false, allowing you to easily control their appearance via CSS.

What layout is used in this demo?

We use JsPlumb's ForceDirected layout in this demonstration. A Force directed layout is a layout in which the edges between vertices are thought of as springs, where the existence of an edge between two vertices has the effect of drawing them closer together.

When the user clicks 'Add a node', a new vertex is added and the layout is re-run. Note though that the position of vertices that have already been processed by the layout is unchanged. You can instruct the force directed layout to recompute every position but from a UX standpoint it's generally a better experience to only run the layout in an incremental fashion, so that is what the Toolkit does by default.

What connector is this?

This demo uses a `Smooth` connector, which is an alias for a straight connector with smoothing switched on, that we added in 7.x.x.

How to configure vertex avoidance for edges?

Further reading

Read more about active filtering in the docs on this page: https://docs.jsplumbtoolkit.com/toolkit/6.x/lib/plugins-overview#active-filtering

Read more about JsPlumb's ForceDirected layout on this page: https://docs.jsplumbtoolkit.com/toolkit/6.x/lib/layout-force-directed

More Demos
See all demos

Flowchart builder application - JsPlumb - JavaScript and Typescript diagramming library that fuels exceptional UIs

Flowchart

Gantt chart builder application - JsPlumb - When you've reached the limit with ReactFlow, we can help!

Gantt

Chatbot builder application - JsPlumb - When you've reached the limit with ReactFlow, we can help!

Chatbot

Callflow builder application - JsPlumb - Angular, React, Vue, Svelte diagramming library

Call Flow

Kanban application - JsPlumb - JavaScript and Typescript diagramming library that fuels exceptional UIs

Kanban

Network topology diagram builder - JsPlumb, leading alternative to GoJS, JointJS and ReactFlow

Network Topology

Database schema builder application - JsPlumb, build diagrams and rich visual UIs fast

Database Schema

Org Chart application - JsPlumb, leading alternative to GoJS, JointJS and ReactFlow

Org Chart

Mindmap builder application - JsPlumb, build diagrams and rich visual UIs fast

Mindmap

Element grouping demonstration - JsPlumb - When you've reached the limit with ReactFlow, we can help!

Nested Groups

Path tracing demonstration - JsPlumb - Angular, React, Vue, Svelte diagramming library

Path Tracing

Hello world demonstration - JsPlumb - When you've reached the limit with ReactFlow, we can help!

Hello World

Image processor application - JsPlumb, industry standard diagramming and rich visual UI Javascript library

Image Processor

Neighbour views dynamic selections demonstration - JsPlumb - Angular, React, Vue, Svelte diagramming library

Neighbourhood Views

Active filtering demonstration - JsPlumb - JavaScript and Typescript diagramming library that fuels exceptional UIs

Active Filtering

Org chart layout demonstration - JsPlumb - When you've reached the limit with ReactFlow, we can help!

Hierarchy Layout

CAD Drawing tools demonstration - JsPlumb - Angular, React, Vue, Svelte diagramming library

Connector Editors

Force directed layout demonstration, org chart layout demonstration - JsPlumb, industry standard diagramming and rich visual UI Javascript library

Layouts

Collapsible hierarchy Italic language family demonstration - JsPlumb - JavaScript and Typescript diagramming library that fuels exceptional UIs

Collapsible Hierarchy

Nested instances desktop example - JsPlumb - JavaScript and Typescript diagramming library that fuels exceptional UIs

Nested Instances