How do I use expressions (Gizmo) to manage colour in properties?

This is an example of using expressions to manage colours of properties based on set ranges, the example is not intended to be restricted to outgoing count (OrgVue metadata) only.

Also, note the ternary format used in expressions below are not required, the if else form is equally valid - see here

Scenario

I have been trying to create a sunburst chart depicting span of control with the following colour coding options:

  • Span of control 1-2: Red
  • Span of control 3: Amber
  • Span of control 4+: Green

 

Option One

 

Of the options discussed, this is the quickest and simplest but not strictly “clean”

Précis: create a measure property (here, MeaProp) with a calculated value: 

 

node.outgoingcount < 2 ? 1 : node.outgoingcount < 3 ? 2 : 3

 

 and then pick the 3 colours required in the colour manager.

 

  • Create a number property, add the expression as default value:

 

 

  • From the right hand pop-out menu, choose Colour-Measure-MeaProp and apply:

 

 

 

Below shows the net effect in card view.

 

Option Two

 

This is a more sophisticated solution than the previous. Option One is not strictly a correct solution as it does not allow for zero. The expression is offset by 1 and nodes with outgoing count 0 will get bucketed with the lower group.

 

Provided the legend is not required, this is a sound solution, as it deals with the offset problem without being overly complex.

 

Précis: create a dimension property with the calculated value:

node.outgoingcount == 0 ? 'gray' : node.outgoingcount < 3 ? "red" : node.outgoingcount < 4 ? "orange" : "green"

And set this property as the passthrough colour dimension.
 

 

  • Create a number property DimProp, add the expression as default value (clearly these are different colours from the original question):

 

 

  • From the right hand pop-out menu, choose Colour-Passthrough-DimProp and Apply:

 

 

 

 

Below shows the net effect in card view:

 

 

Option Three

 

This is the longest but most complete solution. The use of LookUps means it is possible to support both labels and colours within the same property, allowing for more flexible reporting

 

Précis: create a dimension property with the calculated value:

node.outgoingcount == 0 ? “0” : node.outgoingcount < 3 ? "1-2" : node.outgoingcount < 4 ? “3” : “4+” 

and use a lookup to apply custom colours to that property.

  1. Create a colour lookup dataset in the Lookup tab. Note this must have the same save name as the property created later. Below is sample set of colours (the ID is a match to the example later, the colours are unimportant):

Color

ID

sienna

0

gold

1-2

olive

3

navy

4+

 

 

In the main dataset:

  • Create a text property, here called DimLookup as it must match the Lookup dataset name
  • Add the expression as default value (clearly these are different colours from the original question)
  • With option Auto set for the text property, for datasets in the Lookup tab (or those tagged as ‘lookup’) which share the same name as the key of the property, a lookup function will be performed. However, no other properties from the lookup dataset are imported. The lookup will always be performed on the id field of the lookup dataset.

 

  • From the right hand pop-out menu, choose Colour-Passthrough-DimProp and Apply:

 

Below shows the net effect in card view:

 

 

The following shows the value of DimProp as well as the colouration (just choose DimLookup as a displayed property):

 

Have more questions? Submit a request

Comments