An Introduction to OrgVue Expressions (Gizmo)

This is a high level introduction to conceptual areas of OrgVue expressions.  The examples provided will get you started, but for detailed coverage, see the Gizmo Cookbook

Introduction to Gizmo

  • Data in OrgVue is stored as nodes which have properties. Expressions allow you to manipulate these node:property values.
  • Gizmo is a scripting language that is used to write these expressions
  • It has its roots in JavaScript, but has been added to and modified by the OrgVue development team
  • Expressions are the OrgVue equivalent of Excel formulas
  • OrgVue’s scripting language Gizmo allows you to perform querying, calculations, aggregations and transformations.

They can be written in several places:

  1. In the expressions manager
  2. Within a cell (to return a value for that cell)
  3. Within the default value box of a property (preferred)

 

OrgVue generates meta data properties that can be accessed

  • OrgVue generates meta data properties automatically. These properties describe the node itself, and are present as options in a dataset regardless of what other data it contains.
  • Meta-data properties are listed in italics at the bottom of the sidebar property list and the filter control.
  • Typing node.<meta-data property name> will return a value as it would for other properties

Node relationships are stored as a special type of meta data

Node relationship syntax allows you to reference nodes through their hierarchical relationships to one another

Expression

 

Result

node

node

 

Reece Harris

node.parent

node.p

 

Returns his manager

node.siblings

node.s

 

Returns all nodes under the same parent node (team members)

node.children

node.c

 

Returns all his direct reports

node.descendants

node.d

 

Returns all his reports

node.d(start,end level)

     
 

node.d(2)

 

Returns all descendants starting two levels below the selected node

 

node.d(1,2)

 

Selects all descendants between 1 and 2 levels below the node

 

node.d(0,2)

 

Includes the node itself

 

node.d(-1,-2)

 

Selects all ancestors between 1 and 2 levels above the node (parent, grandparent)

 

 

Draft expressions in the expressions manager

  • The expressions manager is useful because it can evaluate expressions on the fly.
  • It is a great way of testing whether your expression is valid, or finding out some data without having to alter the value of any cell in the dataset.

 

Gizmo expressions are written differently to other functions

  • When writing in Excel, or speaking English for that matter, we use a Verb-Object approach, ie. the first thing you do specify the operation you are performing, and then define the variables / parameters on which it acts.
  • OrgVue is very different. It uses a series of objects one after another to gradually specify functions*
  • An expression does two things:
  • it specifies an input (typically a subset of your dataset), and
  • it outputs a value based on the operations performed on that subset.

 

Expressions are constructed using building blocks called objects

  • In OrgVue, expressions are built up gradually by adding together objects separated by dots ('.').
  • You start with the highest level object you can, 'node' or 'nodes()' and then you access properties or values from this object to define a subset of the data on which to perform an operation.

Every time you add something after a dot ('.') it is acting on the input data specified before the dot.

e.g.     (For the object 'node', give me its children, from the object 'this node's children', give me the current salaries, from the object 'this node’s children’s salaries’, give me the sum)

There are 4 types of property you can access for a node:

1.Dataset properties (e.g. ‘Full name’, ‘Grade’)

node.fullname // node.grade

2.Meta-data (OrgVue generated) properties (e.g. depth, orphan)

node.depth // node.isorphan

3.Relations e.g. child, parent, sibling

node.parent // node.sibling

4.Methods / functions e.g. ‘if’, ‘join’, ‘map’

node.if() // node.map()

Any property in the dataset can be theoretically accessed


Building expressions from objects


•    Typing    into the expression manager or a cell primes OrgVue to interpret what follows as an expression
•    The most common objects to follow     are data properties
•    Dataset properties come in 4 main types (these can be set within the Edit Property dialogue):
–    Number
–    String (text)
–    Date
–    Boolean (true or false)

You can also use mathematical operators on objects

Because each expression defines an object that can be acted on, you can also write add, subtract, multiply and divide values easily:

Use standard operator symbols to add ‘+’ , subract ‘-’ , multiply ‘*’ , divide ‘/’

There is also syntax to express more complex operations:

 

Mathematical functions are some of the simpler expressions

  • As well as chaining together properties to return a value - you might want to perform some function.
  • Once you have the appropriate subset of your data, adding a method to your expression will do something to it.
  • Mathematical operations are clear examples of these:

More examples:

nodes().count                           // the total number of nodes in the dataset
                                        // .cnt is another option that only counts numbers
          


nodes().age.avg                         // the average age of people in the dataset


node.salary / node.s.salary.avg * 100   // an employee’s salary as a percentage
                                        // of the average salary of  their peers

 

Have more questions? Submit a request

Comments