Articles in this section
Category / Section

How to Remove Tooltip From Nodes and Connectors in React Diagram?

6 mins read

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 disable them by disabling the tooltip constraints for nodes or connectors respectively in React Diagram.
Below is a code example demonstrating how to disable the tooltip for nodes/connectors

import * as React from 'react';
import * as ReactDOM from 'react-dom/client';
import { DiagramComponent, Inject, DataBinding, HierarchicalTree,ConnectorConstraints,NodeConstraints } from "@syncfusion/ej2-react-diagrams";

// Initialize nodes for diagram
let nodes = [
   {
       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
let connectors = [
   {
       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',
   },
];

export default function App() {

   return (
       <div>
           <DiagramComponent
               id="container"
               width={"100%"}
               height={"550px"}
               nodes={nodes}
               connectors={connectors}
               // Uses layout to auto-arrange nodes on the diagram page
               layout={{
                   // Sets layout type
                   type: 'HierarchicalTree'
               }}

               // Sets the default properties for nodes
               getNodeDefaults={(node) => {
                   node.annotations = [{ content: node.id }];
                   // Define tooltip
                   node.tooltip = {
                       content: node.id
                   };
                   node.width = 100;
                   node.height = 40;
                   // Disable the tooltip for node
                   node.constraints = NodeConstraints.Default & ~NodeConstraints.Tooltip;
                   return node;
               }}

               // Sets the default properties for connectors
               getConnectorDefaults={(connector) => {
                   connector.type = 'Orthogonal';
                   // Define the tooltip for connector
                   connector.tooltip = {
                       content: connector.id
                   };
                   // Disable the tooltip for connector
                   connector.constraints = ConnectorConstraints.Default & ~ConnectorConstraints.Tooltip;
                   return connector;
               }}
           >

               {/* Inject necessary services for the diagram */}
               <Inject services={[DataBinding, HierarchicalTree]} />
           </DiagramComponent>
       </div>
   );
}

// Render the App component into the 'diagram' element in the DOM
const root = ReactDOM.createRoot(document.getElementById("diagram"));
root.render(<App />); 

Sample

Conclusion

I hope you enjoyed learning how to remove tooltips from nodes and connectors in React Diagram.

You can refer to our React Diagram feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications. You can also explore our React 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 explore 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!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied