Release v1.3
Release 1.3 of Cosmos implements a bunch of new features making your work with graphs way more comfortable. Our personal highlight is the trackNodePositionsBy
methods allowing you to continuously get coordinates for chosen nodes and render labels for them.
We deliberately decided not to add labels rendering functionality to Cosmos itself to keep the library tiny. Instead we've created a separate package @interacta/css-labels
that you can use along with Cosmos to add labels to your graph. Check out this CodeSanbox example for copy-pastable sample code.
What's new:
- π€ New API methods
getNodeRadiusByIndex
,getNodeRadiusById
,spaceToScreenPosition
,spaceToScreenRadius
,trackNodePositionsByIds
,trackNodePositionsByIndices
andgetTrackedNodePositionsMap
; - π± Random seed. You can now provide
randomSeed
in the config. It allows you to control the randomness of the layout across different simulation runs. This feature was implemented thanks to @jorrit-hdrn's feedback in issue #19; - π±οΈ Mouse events. You can now add callbacks to
onMouseMove
,onNodeMouseOver
andonNodeMouseOut
events in the config; - βͺ Highlight nodes with a ring when hovered or clicked. Config properties
renderHighlightedNodeRing
allow you to turn on/off highlighting andhighlightedNodeRingColor
allow you to set the color of the ring #24; - π Define scale when zooming to a node programmatically. New arguments
scale
andcanZoomOut
are available in thezoomToNodeById
andzoomToNodeByIndex
methods; - π¨βπ» Renamed Types:
InputNode
toCosmosInputNode
andInputLink
toCosmosInputLink
(old naming will also be available till version 2.0 to preserve compatibility).