Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9238645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:48:36+00:00 2026-06-18T07:48:36+00:00

I want to scale and translate D3 force graph, both at the same time.

  • 0

I want to scale and translate D3 force graph, both at the same time. E.g. On clicking a button it shoud scale to 400% and then make itself center on the screen. This should all happen with a smooth animation effect.

//animate vis to visible area 
vis.transition()
    .duration(2000)
    .attr("transform", "scale(" + someScaleValue + ")" + "center("0,0)");

Doing this, scaling works fine, but graph is not centered. It shifts towards right-bottom corner.

vis.transition()
    .duration(2000)
    .attr("transform", "scale(" + someScaleValue + ")");

Why is scale is getting reset to 100% when I translate it second time.

I also tried using:

vis.transition()
    .duration(2000)
    .attr("transform", "scale(" + scaleValue + ")" + "translate(0,0)");`

This is not working too. Please help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T07:48:37+00:00Added an answer on June 18, 2026 at 7:48 am

    center(0,0) is not a valid transform-definition to be used with transform, as per the spec.

    If you want translate(0, 0) to take the object to the center of the screen (usually the top-left corner of vis), then you might want to set viewBox of the outer svg element to be: "-width/2 -height/2 width height". This would set the co-ordinate system inside the svg element such that the center lies at (0, 0). Alternatively, you can use translate(width/2, height/2).

    Also, each time you call .attr('transform', ...), you overwrite the old value of the transform attribute. This is the possible reason why you are losing the original scaling on translating. The best solution would be to put the vis element inside a g which has the scaling in the transform attribute which remains constant.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Zoom in on a point (using scale and translate) I want to
I want to draw a hull around a grouped force directed graph build with
I grep this string from a SVG file: <g transform=translate(0.000000,980.000000) scale(0.100000,-0.100000) and I want
Given 2 functions Translate(x,y) and Scale(x), I want the camera's position to always be
I want to simultaneously scale and translate a CALayer from one CGrect (a small
I want to scale images these day and find the following example: Example #1
We want to scale, rotate and drag functionality in flash as3. I do have
I want to scale my round rectangle and keep it's radius from been changed.
I want to scale the picture to fit the main div class http://jsfiddle.net/EyW99/ Sorry,
I want to scale out my EC2 instances on AWS. For this I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.