Skip to main content

Pentaho+ documentation is moving!

The new product documentation portal is here. Check it out now at docs.hitachivantara.com

 

Hitachi Vantara Lumada and Pentaho Documentation

util

pentaho.visual.role. util

AMD Module

require(["pentaho/visual/role/util"], function(util) { /* code goes here */ });

The util namespace contains functions for common tasks around dealing with visual roles.

Source: javascript/web/pentaho/visual/role/util.js, line 25

Methods

Name Description
getBestRoleForAddingField(vizModel, fieldName, keyArgs) : Array.<pentaho.visual.role.IAddUsage>

Gets the "best" visual role usage for adding a field to a visualization model.

getHierarchyNextOrdinal(vizModel, hierarchyName) : number

Gets the next unused ordinal of a given hierarchy.

getRoleFirstHierarchy(vizModel, roleName) : string

Gets the name of the first hierarchy of a field mapped to a visual role.

getValidRolesForAddingField(vizModel, fieldName, keyArgs) : Array.<pentaho.visual.role.IAddUsage>

Gets a list of visual role usages for valid additions of a field to a visualization model

testAddField(vizModel, roleName, fieldName, keyArgs) : pentaho.visual.role.IAddUsage

Tests if it would be valid to add a field to a visual role at a specific position.

testAddFieldAtAutoPosition(vizModel, roleName, fieldName, keyArgs) : pentaho.visual.role.IAddUsage

Tests if it would be valid to add a field to a visual role, at one of the possible positions.

Methods Details

getBestRoleForAddingField(vizModel, fieldName, keyArgs) : Array.<pentaho.visual.role.IAddUsage>

Gets the "best" visual role usage for adding a field to a visualization model.

This method selects one of the visual role usages returned by pentaho.visual.role.util.getValidRolesForAddingField by using the following total ordering:

  1. The visual role has its minimum fields requirement satisfied.

  2. The field's data type is such that it matches directly the isContinuous property of the visual role usage.

  3. The field has a hierarchy and the used visual role has other fields of that hierarchy.

  4. The visual role has a lower number of mapped fields.

  5. The visual order of the visual role, according to its ordinal property.

  6. The definition order of the visual role, according to its index property.

Source: javascript/web/pentaho/visual/role/util.js, line 297

Parameters:
Name Default Value Summary
vizModel : pentaho.visual.AbstractModel

The visualization model.

fieldName : string

The name of the field.

keyArgs : object
Optional

The keyword arguments object.

Parameters:
Name Default Value Summary
alternateData : pentaho.data.Table
Optional

An alternate data table which certainly contains all of the currently mapped fields plus the new field.

replaceTarget : boolean | auto
Optional
false

For each of the determined visual role usages, indicates if an existing field at the automatically determined positions should be replaced by the new field.

When "auto" is specified, the target is replaced only if the visual role has no more available space for another field.

Returns:
Name Description
Array.<pentaho.visual.role.IAddUsage>

An array of visual role usages, possibly empty.

See also: pentaho.visual.role.util.testAddFieldAtAutoPosition

getHierarchyNextOrdinal(vizModel, hierarchyName) : number

Gets the next unused ordinal of a given hierarchy.

When the model has no defined data, null is returned. When the model has any undefined mapped fields, null is returned.

Source: javascript/web/pentaho/visual/role/util.js, line 433

Parameters:
Name Default Value Summary
vizModel : pentaho.visual.AbstractModel

The visual model.

hierarchyName : string

The name of the hierarchy.

Returns:
Name Description
number | null

The next ordinal, starting at 0, or null.

getRoleFirstHierarchy(vizModel, roleName) : string

Gets the name of the first hierarchy of a field mapped to a visual role.

Source: javascript/web/pentaho/visual/role/util.js, line 403

Parameters:
Name Default Value Summary
vizModel : pentaho.visual.AbstractModel

The visual model.

roleName : string

The name of the visual role.

Returns:
Name Description
string | null

The name of the hierarchy; null, if none.

getValidRolesForAddingField(vizModel, fieldName, keyArgs) : Array.<pentaho.visual.role.IAddUsage>

Gets a list of visual role usages for valid additions of a field to a visualization model

This method tests adding the field to each of the visualization model's visual roles, by delegating to pentaho.visual.role.util.testAddFieldAtAutoPosition.

Source: javascript/web/pentaho/visual/role/util.js, line 240

Parameters:
Name Default Value Summary
vizModel : pentaho.visual.AbstractModel

The visualization model.

fieldName : string

The name of the field.

keyArgs : object
Optional

The keyword arguments object.

Parameters:
Name Default Value Summary
alternateData : pentaho.data.Table
Optional

An alternate data table which certainly contains all of the currently mapped fields plus the new field.

replaceTarget : boolean | auto
Optional
false

For each of the determined visual role usages, indicates if an existing field at the automatically determined positions should be replaced by the new field.

When "auto" is specified, the target is replaced only if the visual role has no more available space for another field.

Returns:
Name Description
Array.<pentaho.visual.role.IAddUsage>

An array of visual role usages, possibly empty.

See also: pentaho.visual.role.util.testAddFieldAtAutoPosition

testAddField(vizModel, roleName, fieldName, keyArgs) : pentaho.visual.role.IAddUsage

Tests if it would be valid to add a field to a visual role at a specific position.

This method allows moving, appending/inserting or replacing a field in a visual role.

When valid, returns the corresponding visual role usage.

Source: javascript/web/pentaho/visual/role/util.js, line 71

Parameters:
Name Default Value Summary
vizModel : pentaho.visual.AbstractModel

The visualization model.

roleName : string

The name of the visual role.

fieldName : string

The name of the field.

keyArgs : object
Optional

The keyword arguments object.

Parameters:
Name Default Value Summary
alternateData : pentaho.data.Table
Optional

An alternate data table which certainly contains all of the currently mapped fields plus the new field.

fieldPosition : number
Optional

The new index of the field in the visual role's field list.

The default value is the number of fields, causing the field to become the last one.

When specified to an existing position the field is either inserted at that position or replaces the field at that position, depending on the value of keyArgs.replaceTarget.

replaceTarget : boolean | auto
Optional
false

When keyArgs.fieldPosition is specified and a field mapping exists at that position, indicates if it should be replaced by the new field.

When "auto" is specified, the target is replaced only if the visual role has no more available space for another field.

This argument is ignored if keyArgs.fieldPosition is not specified.

Returns:
Name Description
pentaho.visual.role.IAddUsage | null

The resulting visual role usage, when valid; null, otherwise.

See also: pentaho.visual.role.util.testAddFieldAtAutoPosition

testAddFieldAtAutoPosition(vizModel, roleName, fieldName, keyArgs) : pentaho.visual.role.IAddUsage

Tests if it would be valid to add a field to a visual role, at one of the possible positions.

This method is similar to pentaho.visual.role.util.testAddField, however, it automatically determines the first position from end, if any, at which it would be possible to add the field to the visual role.

When valid, returns the corresponding visual role usage.

Source: javascript/web/pentaho/visual/role/util.js, line 196

Parameters:
Name Default Value Summary
vizModel : pentaho.visual.AbstractModel

The visualization model.

roleName : string

The name of the visual role.

fieldName : string

The name of the field.

keyArgs : object
Optional

The keyword arguments object.

Parameters:
Name Default Value Summary
alternateData : pentaho.data.Table
Optional

An alternate data table which certainly contains all of the currently mapped fields plus the new field.

replaceTarget : boolean | auto
Optional
false

Indicates if an existing field at an automatically determined position should be replaced by the new field.

When "auto" is specified, the target is replaced only if the visual role has no more available space for another field.

Returns:
Name Description
pentaho.visual.role.IAddUsage | null

The resulting visual role usage, when valid; null, otherwise.

See also: pentaho.visual.role.util.testAddField