Flowchart with custom behaviours
- In the above sample, we have rendered userhandles link tool icon at the middle left, so that you can draw the connector using that tool.
- We have rendered the userhandles settings tool icon at the top left, so that you can add your custom action in it.
- Also if you double click on the node, the doubleClick event gets triggered. In this event, we have opened the ejDialog box, so that you can enter the additional details to the node in a textbox. Once you entered the details and if you click on the save button, we add that details to the node’s addInfo property. please refer to the code example below.
- In the above sample, we have rendered userhandles link tool icon at the middle left, so that you can draw the connector using that tool.
- We have rendered the userhandles settings tool icon at the top left, so that you can add your custom action in it.
- Also if you double click on the node, the doubleClick event gets triggered. In this event, we have opened the ejDialog box, so that you can enter the additional details to the node in a textbox. Once you entered the details and if you click on the save button, we add that details to the node’s addInfo property. please refer to the code example below.
Thanks for the reply, that helped a lot.
I'm getting this error:
My systemjs config file is pretty much like this one:
Error: (SystemJS) ej is not defined
https://github.com/syncfusion/angular2-seeds/blob/systemjs/systemjs.config.js/#L27-L28
Also, I had to copy the folder node_modules/@types/userhandles to my project's folder, I'm gessing this is not available in npm.
Edit:
The solution was to add:
import 'syncfusion-javascript/Scripts/ej/datavisualization/ej.diagram.min';
|
Query |
Response |
|
Thanks for the reply, that helped a lot.
I'm getting this error:
My systemjs config file is pretty much like this one:
Error: (SystemJS) ej is not defined https://github.com/syncfusion/angular2-seeds/blob/systemjs/systemjs.config.js/#L27-L28 |
The reported issue occurs due to ej-angular2 is not referred in the app.module.ts file. Could you please refer it to resolve your reported issue. Please refer to the code example below.
Code example:
App.module.ts
import { EJAngular2Module } from 'ej-angular2';
However we have created a flowchart sample with system JS and provided the sample below.
Sample: http://www.syncfusion.com/downloads/support/directtrac/general/7z/angular2-seeds-systemjs1357728363
|
|
Also, I had to copy the folder node_modules/@types/userhandles to my project's folder, I'm gessing this is not available in npm. |
Yes, you need to copy the userhandles file to your project because toolbase class could not be implemented in the ej.web.all.d.ts. So only we have used that class in a separate file to render the userhandles tools. |
|
Query |
Response |
|
When I add a new node from the palette, I log the nodes variable and I don't see the new node is being added there. Any idea? |
Could you please confirm us whether you are using drop event to get the dropped node and using diagram.model.selectedItems.children[0] to get the selected node? If yes, please use nodeCollectionChange event in which set the arguments state property as changed to achieve your requirement. please refer to the code example, sample and help documentation below. if we misunderstood your requirement, please provide us more details such as elaborate your requirement in detail with screenshot or video.
Code example:
<ej-diagram id="diagramCore" (nodeCollectionChange)="nodeCollectionChange($event)">
</ej-diagram>
nodeCollectionChange(args){
if(args.state==="changed"){
//get the selectedNode
var node=args.element;
console.log(node.name)
}
}
Help documentation: https://help.syncfusion.com/api/js/ejdiagram#events:nodecollectionchange
|
|
I'm binding to itemClick event on the diagram, and from that event I'm trying to get the node that user clicked on as follows:
var diagram : any = $("#diagramCore").ejDiagram("instance");
var node = diagram.model.selectedItems.children[0]; |
In the itemClick event, please use arguments element property to get the selected node. please refer to the code example, sample and help documentation below.
Code example:
<ej-diagram id="diagramCore" (itemClick)="itemClick($event)">
</ej-diagram>
itemClick(args){
//get the selectedNode
var node=args.element;
console.log(node.name)
}
Help documentation: https://help.syncfusion.com/api/js/ejdiagram#events:itemclick
Also for doubleClick event , please use arguments element property to get the selected node.
|
|
When I change a node name by double clicking on the shape and editing the text, that won't change the name property in the selected node.
What I'm trying to do is save the node variable to database after the user finished editing it to repopulate it on page reload. |
We should not change the object’s name(node/connector/port) at runtime because it is a unique id for all the DOM elements. Also based on the object name, we have changed the object appearance or other functionality. Instead of using nodes name, you can use node’s addInfo property(custom property) and can save it to the database and repopulate it on page reload. Please refer to the code example to define node’s addInfo property.
Code example:
this.nodes = [
{
name: "node1", width: 200, height: 230, offsetX: 200, offsetY: 200,addInfo:"node11"
},
];
Help documentation: https://help.syncfusion.com/api/js/ejdiagram#members:nodes-addinfo
|
Thanks Shyam for asking. Actually the next thing I'm trying is to show text or an icon in the upper right of a node (from withing the node, not outside like the user handle). This text is dynamic and would change. It's basically a counter for the number of times the user clicked on the userhandle Settings (the icon from the upper left).
See the sample image:
https://i.imgur.com/5tuKQCg.png
so, when hovering over the node, it will show 3 on the upper right. If I click on the userhandle on the left, the number will change to 4. If I hover over this number 4, it will show me some tooltip message.
In short, I want to add something like this in the upper right:
{{counter}}
Any update on this?
- In the above sample, we have created a group node with rectangle and ellipse as children.
- By default, we have hidden the ellipse node by setting node’s visible property as false.
- When we hover on the user handles settings tool, the ellipse node is visible and when you click on the settings tool, the numeric value gets increased and updated the ellipse node label with that numeric value.
- When you mouse out the user handles, the ellipse node is hidden. please refer to the video below for your reference.
|
Query |
Response |
|
Also, are you planning on adding two-way data binding support for your Angular component?
<ej-diagram id="diagramCore" [nodes]="nodes" [connectors]="connectors"> </ej-diagram>
So we can use [(nodes)]="nodes" ? |
Yes, we can do two way binding in our diagram control. we have created a sample in which we have done two way binding for nodes. Please refer to the code example and sample below.
Code example:
<button (click)="addNodes()">addNodes</button>
<!--node binding-->
<ej-diagram width="1000px" [(nodes)]="nodes" >
</ej-diagram>
addNodes(){
var test=this.nodes.slice();
test.push({name:"node3"+this.nodes.length,width:100,height:100,offsetX:400 +this.nodes.length,offsetY:400+this.nodes.length});
this.nodes=test;
}
Please refer to the video below in which we have demonstrated how two way binding works for node.
|
|
I've one more issue. I want to use the tooltip on nodes and I followed this tutorial:
https://help.syncfusion.com/js/diagram/tooltip
However, the tooltip shown is text: #nodetooltiptemplate |
The reported issue occurs only if you refer the script template other than index.html file. You should refer script template only in index.html file. please refer to the link below.
We have created a sample in which we have rendered tooltip for nodes.
|
Hi Hussain,Please use drag event to achieve your requirement. in this event, you can do your action when the arguments dragState is completed. Please refer to the code example below.Code example:<ej-diagram id="diagramCore" (drag)= "drag($event)" ></ej-diagram>drag(args) {if (args.dragState === "completed") {//do your action}}Regards,Shyam G
If I used on drag event, how would I get the node I dropped on?
- In diagram, the drop event triggers when you drag a node and drop it onto the another node and it won’t be triggered when dragging an element. so only we have suggested the drag event. The drag event triggers when you drag an diagram element(node, connector). So you need to register both the events in your application as shown in the below code example.
- In drag event, the arguments element property returns an dragged object.
- In drop event, the arguments element property returns an dragged object and the arguments target property returns dropped target object. You can check condition based on it.
- We have diagram builder sample in which you can create flow shapes, BPMN shapes, swimlane, electrical shapes and so on but we don’t have built-in flowchart templates in our diagram and will consider it in future.
- Also, We have demo samples in diagram in which we expose the Diagram functionalities.
- Please let us know if you face any problem while creating flowchart in our diagram, so that we can assist you.
- 28 Replies
- 3 Participants
-
HU Hussain
- Oct 15, 2017 01:34 PM UTC
- May 7, 2018 11:55 AM UTC