Hi,
I found that issue is not the way I calculate, but it was causing by a SVG
Group (g) Element Bounding Box X,Y coordinates. So I just had to subtract
it.
If anyone needs to get the svg boundingBox values use the code (this
returns an array),
d3.select("svg g#groupElement").node().getBBox();
d3.select("svg g#groupElement").node().getBoundingClientRect();
If wants to get from jquery,
$("svg").find("g")[0].getClientRects()[0];
Thanks,
Jerad
On Mon, Jan 26, 2015 at 1:54 PM, Jerad Rutnam <[email protected]> wrote:
> Hi All,
>
> I'm working on a feature in G-Reg (Dependency Graph) using D3. And having
> an issue to centering the graph after zoom-out to screen-size in viewport.
>
> Currently I'm getting these values,
>
> graphScreen = "svg";
>
> mainGraphGroup = "svg g"
>
> var topOffset = (graphScreen.width() - mainGraphGroupWidth)/2,
> leftOffset = (graphScreen.height() - mainGraphGroupHeight)/2;
>
> Is there anyway I can achieve centering by these values? or is there a method
> to achieving this? Any help will be appreciate. Searched on web but couldn't
> find a proper solution for it yet.
>
> Thanks,
> Jerad
> --
> *Jerad Rutnam*
> *Software Engineer - UI*
>
> WSO2 Inc.
> lean | enterprise | middleware
> M : +94 77 959 1609 | E : [email protected] | W : www.wso2.com
>
--
*Jerad Rutnam*
*Software Engineer - UI*
WSO2 Inc.
lean | enterprise | middleware
M : +94 77 959 1609 | E : [email protected] | W : www.wso2.com
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev