Getting Started Part - 1


Posted May 10, 2019 by jsplumbtoolkit

For more details on our products and services, please feel free to visit us at Flowchart, process chart, process flow, diagram, gantt chart

 
Although it is strongly recommended you familiarise yourself with the basic concepts in the jsPlumb Toolkit before writing an app, everybody knows that developers like to get in and get something working right away, then do some research later. So, there are a few ways to jump right in with the Toolkit.
A Gruntfile.js and matching package.json are included in your licensed copy of the Toolkit. This Gruntfile has two targets, allowing you to create a clone of one of the example apps that ship with the Toolkit, or to create a basic 'Hello World' app.
Ingest an existing Community edition instance
This is a useful upgrade path for people who have an existing jsPlumb setup and wish to progressively make use of all the features the Toolkit has to offer. With this method you can instantly add pan/zoom capabilities to your UI, without making any changes to your current code.
It's straightforward to ingest an instance of the Community edition:
var renderer = jsPlumbToolkit.Support.ingest({
jsPlumb:instance
});
Here, instance is some instance of jsPlumb. What you get back is a Surface widget, which is ordinarily the result of a call to the render method of an instance of the Toolkit. The Surface canvas (the element on which you pan and zoom) becomes the jsPlumb instance's Container.
Accessing the underlying Toolkit
Usually when you work with the Toolkit you perform data operations on the Toolkit itself. To access this from the renderer variable returned from an ingest, call this method:
var toolkit = renderer.getToolkit();
Suppressing Rendering
By default, the ingest method will configure a Surface from the jsPlumb instance's Container. You can suppress this behavior and get back just a Toolkit instance like this:
var toolkit = jsPlumbToolkit.Support.ingest({
jsPlumb:instance,
render:false
});
Supplying Rendering Parameters
You can also supply parameters for the Surface widget if you wish to:
var renderer = jsPlumbToolkit.Support.ingest({
jsPlumb:instance,
renderParams:{
consumeRightClick:false,
clampZoom:false
}
});
Here we've instructed the Toolkit to enable right-click on the Surface (very useful when developing), and also to not clamp the movement of the UI when the user zooms. The default behaviour is to clamp the UI to prevent the content from disappearing if the user zooms in such a way that it ordinarily would.
________________________________________
Adding Nodes after Ingest
Once you've ingested your existing jsPlumb instance you have two options for adding new nodes:
Use your existing mechanism and advise the Surface via its ingest method.
Clone an example app via Grunt
In the root directory of your Toolkit files, run this command (this is assuming that you have Grunt installed on your computer, instructions for which are outside the scope of this document):
grunt clone --app=database-visualizer --o=
Here we've cloned the database-visualizer app. You can clone any of the demonstrations that ship with the Toolkit. The full list is:
• layouts
• multiple
• database-visualizer
• flowchart-builder
• groups
• angular-1.x-groups
• angular-1.x
• angular
• angular-skeleton
• angular-groups
• react
• react-skeleton
• vue
If your output directory already exists, the clone will not proceed. Otherwise, the app will be cloned into the appropriate directory, and you can access it via the index.html. Remember to host the app with an http server and not try to use it by opening the local file.
Create an empty-ish app via Grunt
grunt create --o=
This will create a basic skeleton app in , with just enough functionality for you to see something working which you can then enhance and adjust.
Create an empty app manually
There are a million different ways to create a page from scratch, so here we'll talk only about the basic imports required:
CSS
jsplumbtoolkit-defaults.css (found in the /css directory) contains suggested defaults for your CSS, and it is recommended that you include it. Inside this file you will see comments for each style that detail whether or not it is an absolute requirement, or a suggestion, or just a cosmetic style used by the Toolkit to demonstrate how things should be setup.
Javascript
From version 1.2.0 the Toolkit bundles the required Community edition, so you need only the import the jsplumbtoolkit-x.x.x.js script.
And of course you'll likely have your own JS file containing your app code. Remember always to wrap your app's initialization like this:
jsPlumbToolkit.ready({
// your code here
});
This method wraps jsPlumb's ready function and ensures that everything is in order before you start to make calls to the API.
For more details on our products and services, please feel free to visit us at Flowchart, process chart, process flow, diagram, gantt chart
-- END ---
Share Facebook Twitter
Print Friendly and PDF DisclaimerReport Abuse
Contact Email [email protected]
Issued By jsplumbtoolkit
Country United States
Categories Business
Last Updated May 10, 2019