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?
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.
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.
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.
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.
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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With