Search

Node Styling

Styling

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: Sets width and height to get rectangular nodes.
  • radius: Sets corner radius to node border.
  • label: Accepts an array of one or more objects to create multiple labels with a large number of customizable properties such as image, position, border, margin, padding or textAlignment. 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.

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.

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 vertical position set
  • set it to the same value if the preceding label has a vertical position set

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 label
  • fontSize:'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.

Label margin and padding

You can set margin and padding to fine-tune label spacing and position:

  • Specify margin by 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 padding property which is specified, and behaves like, W3C CSS padding. This doesn't apply to image labels because the image always fills the label.

Terms of use

These terms do not alter or supersede any existing agreements between you (or your employer) and us.

By accessing or using any Content you agree to be bound by these Terms of Use. Please review these terms carefully before using the website.

The contents of this website, including but not limited to any text, code samples, API references, schemas, interactive tools, and other materials (collectively, the 'Content'), are made available for informational and internal evaluation purposes only. All intellectual property rights in the Content are reserved. No licence is granted to use the Content for any commercial purpose, or to copy, distribute, modify, reverse-engineer, or incorporate any part of the Content into any product or service, without our prior written consent.

This Content is provided “as is” and “as available,” without any representations, warranties, or guarantees of any kind, whether express or implied, including but not limited to implied warranties of merchantability, fitness for a particular purpose, non-infringement, or accuracy. To the fullest extent permitted by applicable law, we expressly exclude and disclaim all implied warranties, conditions, and other terms that might otherwise be implied.

We disclaim all liability for any loss or damage, whether direct, indirect, incidental, consequential, or otherwise, arising from any reliance placed on the Content or from your use of it, to the fullest extent permitted by applicable law. By continuing to access or use the Content, you acknowledge and agree to these terms.