Articles in this section

How to Stretch Node Width to Viewport Width in React Diagram?

This article explains how to stretch a node’s width to fit the viewport width in React Diagram. To stretch a node’s width to fit the viewport width, you can adjust the node size based on the diagram’s viewport settings. The viewportWidth and currentZoom properties within the diagram’s scrollSettings help you calculate the appropriate node width, ensuring it aligns with the visible area of the diagram.

Below code snippet explains how to stretch node width to viewport width.

function updateImageNode() {
   let node = diagramInstance.getObject('headerNode');
   node.width =
     diagramInstance.scrollSettings.viewPortWidth +
     diagramInstance.scrollSettings.viewPortWidth *
       diagramInstance.scrollSettings.currentZoom;

        //to preview zoom in and zoom out
       diagramInstance.scrollSettings.maxZoom = diagramInstance.scrollSettings.currentZoom;
       diagramInstance.scrollSettings.minZoom = diagramInstance.scrollSettings.currentZoom; 
 } 

Refer to the working sample for additional details and implementation: Sample

Conclusion

We hope you enjoyed about how to stretch node width to viewport width in React Diagram

You can refer to our React 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 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 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, BoldDesk Support, 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)
Access denied
Access denied