bumbeishvili / org-chart

Highly customizable org chart. Integrations available for Angular, React, Vue
https://stackblitz.com/edit/web-platform-o5t1ha
MIT License
928 stars 330 forks source link

Limiting panning of chart #189

Open BDOXHN opened 2 years ago

BDOXHN commented 2 years ago

Good day! By default panning of chart - infinite. User can hide the chart from the screen, which I would really not like in my situation.

Is there any way the panning to be only be inside the chart rather outside of it? Or maybe panning with limit by tree size (with dynamically update by opened or closed subtrees)

I tried edit code in d3-org-chart.js at line: behaviors.zoom = d3.zoom().on("zoom", (evenbt, d) => this.zoomed(event, d).scaleExtent(attrs.scaleExtent)

with adding: .translateExtent([[-1000, -1000],[1000, 1000]])

but I dont know how can i get current width and height of chart, that will be update after i open or close subtrees.

bumbeishvili commented 2 years ago

Currently, there is no panning limit, only a zoom limit -

Which you can control by overriding chart.scaleExtent([0.001, 20])

If it helps, you can get the current width and height of the graph using chart.svgWidth() and chart.svgHeight()