What is the difference between D3 and jQuery?

前端 未结 7 1019
挽巷
挽巷 2021-01-29 23:54

Referring to this example:

http://vallandingham.me/stepper_steps.html

it seems that the D3 and jQuery libraries are very similar in the sense that they both do D

7条回答
  •  忘了有多久
    2021-01-30 00:28

    d3 has a silly description. jQuery and d3 are not at all similar, you just don't use them for the same things.

    jQuery's purpose is to do general dom manipulation. It's a general purpose javascript toolkit for anything you might want to do.

    d3 was primarily designed to make it easy to make shiny graphs with data. You should definitely use it (or something similar, or something built on top of it) if you want to make graphical visualizations of data.

    If you want a general purpose JS library for all your interactive form needs, consider jQuery or proto or mootools. If you want something tiny, consider underscore.js. If you want something with dependency injection and testability, consider AngularJS.

    A General comparison guide from wikipedia.

    I can see why someone would think they are similar. They use a similar selector syntax -- $('SELECTOR'), and d3 is an extremely powerful tool for selecting, filtering, and operating on html elements, especially while chaining these operations together. d3 tries to explain this to you on its home page by claiming to be a general purpose library, but the fact is that most people use it when they want to make graphs. It is pretty unusual to use it for your average dom manipulation because the d3 learning curve is so steep. It is, however, a far more general tool than jQuery, and generally people build other more specific libraries (such as nvd3) on top of d3 rather than using it directly.

    @JohnS's answer is also very good. Fluent API = method chaining. I also agree about where the plugins and extension lead you with the libraries.

提交回复
热议问题