I'd like to do something a little bit out of the ordinary with force layouts (for visualizing graphs). Constellations and all are fun to look at, but for timeseries data, it's not that helpful. I'd like to be able to constrain the layout by some axis, for example, by laying out the nodes according to the time they appear in a dataset, while still retaining the "bouncyness" of the visualization. Is this possible using d3?
相关问题
- Highlight parent path to the root
- Avoid overlapping of nodes in tree layout in d3.js
- d3.js moving average with previous and next data v
- How to determine +/- sign when calculating diagona
- Seaborn HeatMap - How to set colour grading throug
相关文章
- Mercurial Commit Charts / Graphs [closed]
- D3.js: Stop transitions interrupting on mouseover?
- Adding text to the center of a D3 Donut Graph
- rect collision detection d3js
- Pausing and resuming a transition
- D3 grouped bar chart: How to rotate the text of x
-
Error:
attribute d: Expected number, “MNaN, - how to use a CDN inside a React component
To elaborate on my comment, yes, this is perfectly possible. The force layout does not in fact position the nodes itself, it merely computes the positions. In the handler of the
tick
event you usually provide the function that takes care of the positioning. There, you can add arbitrary constraints that restrict how the nodes can move.Taking one of the stock examples, you could do things like the following to restrict the x coordinate to within +-10 of the intended position with unrestricted y.
Here is another example that uses the force layout to position labels. There, the x position is ignored (i.e. constant) and only the y is affected by the layout.
Webcola is a great tool for creating constraint-based layouts with D3.JS.
See https://github.com/tgdwyer/WebCola