labella.js | Placing labels on a timeline without overlap | Frontend Framework library
kandi X-RAY | labella.js Summary
kandi X-RAY | labella.js Summary
"Labels should be beautiful.". If you try to place labels for points on a timeline (or any 1D space), one common problem is the labels often overlap. How about making the labels push each other and find where they can stay with overlapping?. Moreover, if you are looking for a ready-to-use timeline component with Labella's smart labeling instead of building your own timeline from scratch, check out d3Kit-timeline. Note: For users who are upgrading from v0.x.x to v1.x.x. The API has changed. force.start() and force.on() are deprecated. Both are replaced by force.compute() which has to be called slightly differently. Please read the change logs.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of labella.js
labella.js Key Features
labella.js Examples and Code Snippets
Community Discussions
Trending Discussions on labella.js
QUESTION
Ok, don't laugh. I'm trying to make curvy edges that detour around nodes that are between the source and target. I couldn't figure out how to do it (I read http://js.cytoscape.org/#style/bezier-edges, but didn't understand it), so I put fake nodes into empty places on the way from source to target and made a series of edges. The result is pretty ridiculous:
What's the right way to do this? I was aiming for something slightly more elegant, like:
from http://twitter.github.io/labella.js/
Based on @maxkfranz's advice below I did get a lot closer:
but finally decided to give up. It's taking too long. Going back to straight edges. If anyone ever reads this and can describe a way to accomplish my goal in Cytoscape.js or some other tool, I'd love to hear it.
To be clear about what I'm doing before giving up, I:
- lay out nodes on grid such that there is always an empty grid cell between any two nodes on the same row (this is less than ideal because the empty cells should preferably be as narrow as possible)
- for every row on the grid layout between source and target nodes:
- specify a "waypoint" closest to the direct path from source (or the previous waypoint) to target that passes through an empty grid cell,
- convert row/col coordinates of the waypoint into pixel coordinates,
- convert those into distance/weight values (based on function described here)
- use those for unbundled bezier control points.
Here's the most relevant part of my code:
...ANSWER
Answered 2017-Jan-14 at 04:39The set of control points for an edge is defined by N weights (w1, w2, ... wN) and N respective distances (d1, d2, ... dN).
The weight defines how close a point is to the source or target, and the distance controls how far away from a source-target line the point should be. The sign of the distance controls the side of the source-target line that the curve lies on (i.e the handedness). See the docs for more info: http://js.cytoscape.org/#style/bezier-edges
The following diagram summarises the values for a single point for simplicity, but you could extend this to multiple points:
Note that the above image assumes edge-distances: node-position
, whereas the following diagram assumes edge-distances: intersection
(default):
For complex usecases, edge-distances: node-position
makes calculations easier -- but you have to be more careful to not specify points in the node body. The end result is almost the same for these examples, so I didn't update the curve. Larger nodes of different sizes would make the difference between these cases more apparent.
A bezier's control point does not intersect the control point. The control point "pulls" the curve towards the point. For quadratic bezier like in Cytoscape, the distance of the curve will be half that of the control point. For more info on beziers, see Wikipedia: https://en.wikipedia.org/wiki/B%C3%A9zier_curve
On the other hand, segment edges will intersect the points you specify, because they're just a series of straight lines: http://js.cytoscape.org/#style/segments-edges
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install labella.js
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page