I'm creating a zoomable scatterplot based on the following examples:
What Career Should I Invest In?
I've added a button to change the category for the x axis from Calories to Carbs and the chart is updated correctly. But when I try to zoom with the new domain the zooming uses the old domain. How can I update the zoom functionality for the new domain?
The current implementation can be found here.
You just need to rebind the new scales to the behavior.
First put the zoom behaviour function in a variable so you can access it later: Your original code...
should be this:
Second, in your function change, you bind the scales to the behavior. So instead of:
you just change one line:
For documentation, see http://bl.ocks.org/mbostock/3892928