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 8544449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:33:39+00:00 2026-06-11T12:33:39+00:00

modify this question again, because the solution does not work in the new version

  • 0

modify this question again, because the solution does not work in the new version of the library d3 (3.0.3), so I come to ask for some help again would be very grateful.

Here is the new code with the library d3 (3.0.3):

https://gist.github.com/4495104
http://bl.ocks.org/4495104/e7a7589098140dff36df7ab2a824d71072bc3be4

According to what I’ve worked, the error should be in the line “491”.

// Reset the domain relative to the current zoom offsets.
    x.domain(x0.range().map(function(x) {
      return (x - translate[0]) / scale; 
    }).map(x0.invert));

We are changing the x.domain every second with setInterval, because we want to generate the appearance that the background is moving, but every time you run an event d3.behavior.zoom() (zoom or panning) the x.domain automatically switches to the initial values​​. In the next link you can review the problem.

http://jsfiddle.net/cristian540/Uy6bW/11/

  • 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-11T12:33:40+00:00Added an answer on June 11, 2026 at 12:33 pm

    If you change the scale’s domain programmatically, you need to reassign the scale to the zoom behaviour. This is because the zoom behaviour stores a clone of the scale internally for computing the new domain for new scale and translate offsets. So if you don’t reassign the scale, it continues to use the (old) cloned scale.

    I’ve updated the documentation to include a note about this.

    There is an additional complication, which is that the zoom’s x- and y-scales should represent the domains at zoom scale=1. So you actually need to keep your own clone of the current scale(s) at zoom scale=1 and apply the offset to both the clones and the current scales.

    Then, you may also need to invert the current zoom translate and scale, depending on the exact behaviour that you need.

    So it should look something like:

    var x0 = d3.scale.linear().domain(…).range(…), // initial scale
        x = x0.copy(); // copy to use for axes and zoom behaviour
    
    setInterval(function() {
      var translate = zoom.translate(),
          scale = zoom.scale(),
          xd = x0.domain(),
          dx = 1;
    
      // Set a new x-domain: offset by dx.
      x0.domain([xd[0] += dx, xd[1] += dx]);
    
      // Set the zoom x-domain (this resets the domain at zoom scale=1).
      zoom.x(x.domain(xd));
    
      // Reset the domain relative to the current zoom offsets.
      x.domain(x0.range().map(function(x) {
        return (x - translate[0]) / scale;
      }).map(x0.invert));
    }, 1e3);
    

    Example of this in action.

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

Sidebar

Related Questions

This is an extension for this question asked an hour ago. We cannot modify
Friends, This Ask Tom thread which I found via another SO question, mentions Table
I don't know how to ask this question thru google, i try but what
Forgeive me if this is a dumb question, im very new to SL, just
I have done some research on this question and most answers are a few
This is my first question on StackOverflow.com and I'm not sure if this is
Not sure how to ask a followup on SO, but this is in reference
How do I modify this CSS to apply a scroll bar with fixed header?
How can I modify this: /services/type/single_dwelling/ to this: /ajax/services/single_dwelling/development Currently I have: linkUrl =
I'm trying to modify this: jquery desktop by adding a input field inside one

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.