Kumu Blog

Tools and practices for tackling complex systems.

Introducing label templates

Sometimes you want a little more context than the default labels provide. For example, you might want to pull in location, display the strength of a connection, or show an element's rank. With sensitive data you may want to turn off labels entirely or replace the person's name with their organization or role.

Label templates, a new feature we're releasing today, allow you to easily accomplish any of those in seconds:

connection {  
  label: "{{amount owed}}";
}

And voila!

label template for amount owed

You can easily customize the label in the advanced tab of perspectives. Let's look at a few examples:

Turning off labels

The easiest way to do this is through the @settings block:

@settings {
  label: none;
}

If you just wanted to turn off labels for elements with type "person":

person {  
  label: none;
}

Pulling in attributes

The general format for pulling in an attribute is {{attribute name}}. Let's say we wanted to include the "location" attribute in place of the default label for elements:

@settings {
  element-label: "{{location}}";
}

Or, you may want to include "location" in addition to the element label. In this case, we can do a bit of extra magic by using a double space to cause a line break and include the location below the default label:

@settings {
  element-label: "{{label}}  {{location}}";
}

Adding custom text

As you probably already guessed, you're not limited to just attribute values for the labels. Maybe you want to make it explicit what the location value represents:

@settings {
  element-label: "Born in {{location}}";
}

Or maybe you want to override the default label for an element:

#john-doe {
  label: "Johnny Boy";
}

Hope that's enough to get you started. We're really excited about the possibilities label templates open up and the massive amount of time they can save. Enjoy!

Subscribe for updates

Loading comments...