Giter Site home page Giter Site logo

Comments (4)

mbostock avatar mbostock commented on April 28, 2024

None of those modifications are superfluous in the general case. Various changes to the axis configuration can require those updates:

  • The axis tick size can change.
  • The axis orientation can change.
  • A prior axis transition can be interrupted, preventing the tick opacity from reaching 1.

(You also removed a few essential features of the axis, like a default appearance and cross-fading ticks during a transition.)

You could move a few things to entering elements if you require that the axis orientation doesn’t change. But then you’d have to document that the way to change the axis orientation is to remove the old axis and add a new axis, rather than just re-applying a new axis with the new orientation.

You could avoid setting the entering line’s x2 and entering tick’s x attributes in the case that you’re updating the axis instantaneously (since they are subsequently set on enter + update), but this is a relatively minor optimization.

You could avoid setting a few attributes separately on each tick, but it would require restructuring the axis so that the tick labels and tick lines are grouped separately, rather than grouping the label and line for each tick together. Which would mean you’d need to set the transform attribute on twice as many elements to move the ticks into place, or using attributes to position the tick labels and lines rather than transforms.

I could maybe see changing the axis to assume a fixed orientation; see e1d90ce. (I also changed it to only define default styles the first time the axis is applied.) I am sure it will trip up at least some users in the future, but maybe that’s acceptable if documented. I could also maybe see the axis detecting an orientation change and patching the difference just in that case, though I fear that adds complexity to the implementation…

from d3-axis.

mbostock avatar mbostock commented on April 28, 2024

I’ve merged the aforementioned optimizations and documented the requirement that the axis orientation is fixed. If you have other suggested optimizations, please let me know. Thank you.

from d3-axis.

nponeccop avatar nponeccop commented on April 28, 2024

Can you update http://bl.ocks.org/mbostock/db6b4335bf1662b413e7968910104f0f to use alpha 50, as it incorporates the above performance improvements?

Wrapping draw calls with d3.timeout to avoid multiple updates per frame improves framerate in that example too, but makes code bulky and less suitable for learning. But you could add a note to the block's readme.

from d3-axis.

mbostock avatar mbostock commented on April 28, 2024

I updated it.

from d3-axis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.