There are various reasons why your charts may need a custom node design:
- A high level of information (e.g. several pieces of information shown by single node)
- Dynamically changing data (e.g. strings or numbers in varying length)
- Different types of data (e.g. visual or numeric information, relative amounts)
- The specific design language of your application
ReGraph supports different customization levels from simple to more advanced node styles.
Below are some examples of the ReGraph API for node styling:
shape: Setswidthandheightto get rectangular nodes.radius: Sets corner radius to nodeborder.label: Accepts an array of one or more objects to create multiple labels with a large number of customizable properties such asimage,position,border,margin,paddingortextAlignment. This feature is currently in beta. See the Node Label API for details.imageAlignment: controls scale and position of images and font icons inside nodes.
For more examples, see also the Node Gallery and Advanced Node Gallery stories.
ReGraph Example
Label positioning
Labels are anchored to nodes from the outside or from the inside.
The position property accepts a string compass value to set the label outside the node, or an object with vertical and/or horizontal properties to set the label inside the node.
Set the position of images and font icons within node labels using position and margin. You can also control the scale of font icons using fontSize.
ReGraph Example
Multiple inline labels
By default, multiple labels on a node are stacked vertically from the top. There are two ways how to position multiple labels on the same line using the vertical option of position:
- set it to 'inherit' if the preceding label label has no
verticalposition set - set it to the same value if the preceding label has a
verticalposition set
ReGraph Example
Label sizing and label content
A label can either contain an image or text-based information such as text or a font icon.
Image labels have image set, and can be sized by specifying both maxWidth and maxHeight. You can also specify border and position them using margin and position, but other label settings are ignored.
Labels containing text or a font icon are sized, by default, to fit the content that's inside. In this case the ReGraph API lets you modify the label size and also customize the content inside:
minWidth,minHeight: Set custom label size.textAlignment: Sets the alignment of content inside a labelfontSize:'auto': Scales the font to any label size and zoom level.textWrap:'normal': Wraps the content on whitespace.maxWidth,maxHeight: Controls maximum size when text wrapping or automatic font sizing are used.
ReGraph Example
Label margin and padding
You can set margin and padding to fine-tune label spacing and position:
- Specify
marginby setting the distance between the label edge and either another label edge, or its parent node edge. This API behaves like, and can be set similarly to, W3C CSS margin. - For non-image labels, set the
paddingproperty which is specified, and behaves like, W3C CSS padding. This doesn't apply to image labels because the image always fills the label.
