Query |
Response | |
|
Your requirement can be achieved using html template only. Currently, we don’t have template support for the html node. We have logged “Template support for HTML node” as a feature and you can track the status of the feature from the below link.
Feedback link:
| |
|
We have created a sample in which we have set an annotation for the node on mouseOver event. Please refer to a code example and sample below.
Code example:
|
<ejs-diagram #diagram id="diagram" width="100%" height="580px" [getConnectorDefaults]='connDefaults' [getNodeDefaults]='nodeDefaults' [layout]='layout' [dataSourceSettings]='data' [snapSettings]='snapSettings' [selectedItems]="selectedItems" [getCustomTool]="getCustomTool"></ejs-diagram>
//define userhandles in selected items
public selectedItems: SelectorModel = {
constraints: SelectorConstraints.UserHandle,
userHandles: this.handles
};
//Defines the user handle collection for nodes in diagram
public handles: UserHandleModel[] = [
{
name: 'orgEditHandle', pathColor: 'white', backgroundColor: '#7d7d7d', borderColor: 'white',
pathData: 'M 42.65 30.41 L 67.5 53.99 L 41.2 78.73 C 39.41 80.42 37.34 81.27 34.99 81.27 C 32.65 81.27 30.57 80.49 28.78 78.93 L 25.05 82.44 L 0 82.44 L 16.36 67.05 C 14.57 65.36 13.67 63.41 13.67 61.2 C 13.67 58.99 14.57 56.98 16.36 55.16 z M 78.42 25.49 C 78.57 0 78.73 0.01 78.88 0.01 C 81.09 -0.12 83.09 0.66 84.88 2.35 L 97.52 14.04 C 99.17 15.86 100 17.87 100 20.09 C 100 22.29 99.17 24.24 97.52 25.93 L 71.84 50.09 L 46.79 26.51 L 72.47 2.35 C 74.15 0.77 76.13 -0.02 78.42 25.49 z',
side: 'Right', offset: 0, horizontalAlignment: 'Center', verticalAlignment: 'Center'
},
];
public getCustomTool: Function = this.getTool.bind(this);
public getTool(action: string): ToolBase {
let tool: ToolBase;
if (action === 'orgEditHandle') {
//this block executes while selecting a userhandle
let orgEditTool: OrgEditHandleTool = new OrgEditHandleTool(this.diagram.commandHandler);
orgEditTool.diagram = this.diagram;
orgEditTool.dialog = this.dialog;
orgEditTool.textbox = this.textbox;
return orgEditTool;
}
return tool;
}
class OrgEditHandleTool extends ToolBase {
public diagram: Diagram = null;
public dialog: DialogComponent = null;
public textbox: TextBoxComponent = null;
public mouseDown(args: MouseEventArgs): void {
this.inAction = true;
super.mouseDown(args);
}
public mouseUp(args: MouseEventArgs): void {
if (this.inAction) {
if (this.diagram.selectedItems.nodes.length > 0) {
//set a node value in the textbox
this.textbox.value =this.diagram.selectedItems.nodes[0].annotations[0].content;
//open the dialog
this.dialog.show()
}
}
super.mouseUp(args);
}
} |