How to Remove Tooltip From Nodes and Connectors in Angular Diagram?
In our Graphical User Interface (GUI), a tooltip appears when you hover your mouse over an element. This message provides additional information to enhance your experience and understanding of the interface.
If you prefer not to see these tooltips, you can easily remove them by disable the tooltip constraints for nodes or connector respectively in Angular Diagram .
Below is a code example demonstrating how to disable the tooltip for nodes/connectors
import { Component, ViewEncapsulation, ViewChild } from '@angular/core';
import { DiagramComponent, Diagram, NodeModel, ConnectorModel, LayoutModel, DiagramModule,
HierarchicalTreeService, HierarchicalTree,
NodeConstraints,
ConnectorConstraints} from '@syncfusion/ej2-angular-diagrams';
Diagram.Inject(HierarchicalTree);
@Component({
imports: [ DiagramModule ],
providers: [HierarchicalTreeService],
standalone: true,
selector: "app-container",
template: `<ejs-diagram #diagram id="diagram" width="100%" height="580px" [nodes]="nodes" [connectors]="connectors"
[getNodeDefaults]="getNodeDefaults" [getConnectorDefaults]="getConnectorDefaults" [layout]="layout"> </ejs-diagram>`,
encapsulation: ViewEncapsulation.None
})
export class AppComponent {
@ViewChild("diagram")
public diagram?: DiagramComponent;
public layout?: LayoutModel;
//Initialize nodes for diagram
public nodes: NodeModel[] = [
{
id: 'Steve-Ceo',
},
{
id: 'Kevin-Manager',
},
{
id: 'Peter-Manager',
},
{
id: 'John-Manager',
},
{
id: 'Mary-CSE',
},
{
id: 'Jim-CSE',
},
{
id: 'Martin-CSE',
},
];
//Initialize connectors for diagram
public connectors: ConnectorModel[] = [
{
id: 'Steve-Ceo_Kevin-Manager',
sourceID: 'Steve-Ceo',
targetID: 'Kevin-Manager',
},
{
id: 'Steve-Ceo_Peter-Manager',
sourceID: 'Steve-Ceo',
targetID: 'Peter-Manager',
},
{
id: 'Peter-Manager_John-Manager',
sourceID: 'Peter-Manager',
targetID: 'John-Manager',
},
{
id: 'Peter-Manager_Mary-CSE',
sourceID: 'Peter-Manager',
targetID: 'Mary-CSE',
},
{
id: 'Kevin-Manager_Jim-CSE',
sourceID: 'Kevin-Manager',
targetID: 'Jim-CSE',
},
{
id: 'Kevin-Manager_Martin-CSE',
sourceID: 'Kevin-Manager',
targetID: 'Martin-CSE',
},
];
//Sets the default properties for all the Nodes
public getNodeDefaults(node: NodeModel): NodeModel {
node.annotations = [{ content: node.id }];
//define tooltip
node.tooltip = {
content : node.id
}
node.borderColor = 'white';
node.width = 100;
node.height = 40;
node.backgroundColor = '#6BA5D7';
node.borderWidth = 1;
node.width = 100; node.height = 40;
//disable the tooltip for node
node.constraints = NodeConstraints.Default & ~NodeConstraints.Tooltip
return node;
}
//Sets the default properties for all the connectors
public getConnectorDefaults(connector: ConnectorModel): ConnectorModel {
connector.tooltip = {
content : connector.id
}
connector.type = 'Orthogonal';
//disable the tooltip for connector
connector.constraints=ConnectorConstraints.Default & ~ConnectorConstraints.Tooltip
return connector;
}
ngOnInit(): void {
//Uses layout to auto-arrange nodes on the Diagram page
this.layout = {
//Sets layout type
type: 'HierarchicalTree'
}
}
}
Conclusion
I hope you enjoyed learning how to remove tooltip from nodes and connectors in Angular Diagram.
You can refer to our Angular Diagram feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Angular Diagram example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!