Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is d3 a good choice for building a free-form diagram editor? [closed]

I am planning on writing a web-based diagram editor. If it were for the desktop, I'd have chosen Eclipse GEF as the platform to build it.

For the web, I'm considering d3.js, but I'm a bit worried that almost every example and article that I came across on d3 was for visualizing data, and not really for an interactive point-and-click, select-and-connect, drag-and-draw kind of usage.

I might still be able to force-fit d3 into the making of this editor, but then I wonder if d3 would evolve in ways that would make it continually painful to maintain the editor going forward.

So my question to the community is: from a software architecture standpoint, is d3 a good choice for building a free-form diagram editor? Can you pont me to API, d3 internal code, articles, or examples that would prove that such an editor can stand in the long term?

like image 647
Pradyumna Avatar asked Jun 11 '13 16:06

Pradyumna


People also ask

What format does D3 use to create graphics?

D3 uses SVG to create and modify the graphical elements of the visualization. Because SVG has a structured form, D3 can make stylistic and attribute changes to the shapes being drawn.

What is D3 explain about the big data visualization using D3 with example?

D3. js is a JavaScript library for creating visualizations like charts, maps, and more on the web. Unlike many other data visualization libraries that provide ready made charts, D3 gives you lots of creative freedom as you have total control over the visualizations you create.

What is D3 and SVG?

Before we dive into D3, we'll take a quick look at SVG, which stands for Scalable Vector Graphics. SVG is a markup language for graphics. D3 is not limited to SVG. You can also use D3 to create visualizations using canvas, HTML elements, for example.

Can you use D3 in react?

React Faux DOM It's a way to keep most of D3's utility and combine it with React. The faux DOM is placed to allow D3 a virtual DOM so you can still access all of D3's API. At the same time, React remains in control of the virtual DOM and ultimately the real DOM, allowing it to control state and transitions.


1 Answers

If the question were "Can D3 help me with the SVG interactions involved in creating a web-based diagram editor?", then the answer would be "Yes, a little". But you're setting out on a very large project, and D3 can only help you with some parts of it.

Examples of areas where D3 can be of assistance:

  • Rendering a set of existing shapes out of your diagram definition: http://bl.ocks.org/explunit/4659227
  • Doing some limited auto-routing of new connector paths: http://bl.ocks.org/explunit/5603250 But you're going to have a lot of extra work once you need to go beyond the automatically routed connectors.
  • Collision Detection: http://bl.ocks.org/mbostock/3231298 Though this is more just sample code than D3 itself.
  • Brushes for region selection: Fine-grained event handling with D3 brushes
  • Bounded drag & drop: http://bl.ocks.org/mbostock/1557377

Overall I think you're probably looking for a higher-level framework unless you are prepared to control almost every aspect of what D3 does.

You are right that most of the helper methods that D3 provides are geared toward data visualization, but it does provide a thin layer over SVG that can be helpful for a general-purpose project like you describe.

As to whether D3 will evolve in a direction that might make it less suitable for this project in the future: only @mbostock can know for sure, but given the design of the API which lets it be used for either SVG or HTML node manipulation, I think it's safe to say that it will remain fairly low level. And you've probably seen this example before but it's a good illustration of the library's power beyond charts & graphs.

like image 176
explunit Avatar answered Sep 19 '22 02:09

explunit