Initializing help system before first use

# Formatter

Data formatting and system default format definitions

### Method summary

name | description
--- | ---
formatEntityValue | For a given entity convert the original value to the display value.
formatNumber | Format a number using a specified format definition.
getFormattedLabel | For a given entity in a scenario get the formatted label for the original value.
setEntityFormatter | Attach a formatting function for a specific entity.

### Methods

formatEntityValue ( entity, originalValue, key ) → {string}

  For a given entity convert the original value to the display value.

  ##### Parameters:

  Name | Type | Argument | Description
  --- | --- | --- | ---
  entity | ModelEntity |  | The entity instance
  originalValue | string |  | The original value
  key | Array.<*> | optional | The array key for the value, if applicable

  Returns:

  Type | Description
  --- | ---
  string | The formatted value

  ##### Example

      var view = insight.getView();
      var entity = view.getApp().getModelSchema().getEntity(name);
      insight.Formatter.formatEntityValue(entity, 1234);

  Back to Top
formatNumber ( original, format, locale ) → {string}

  Format a number using a specified format definition.

  ##### Parameters:

  Name | Type | Argument | Description
  --- | --- | --- | ---
  original | number | string |  | Original number
  format | string |  | Format definition
  locale | string | optional | Locale to use for formatting

  Returns:

  Type | Description
  --- | ---
  string | The formatted number as a string. Empty string if original is null or undefined.

  ##### Example

      insight.Formatter.formatNumber(12.75, '00#'); // returns the string '013'

  Back to Top
getFormattedLabel ( entity, scenario, originalValue, key ) → {string}

  For a given entity in a scenario get the formatted label for the original value. Will discover associated label entity and use corresponding value from that.

  ##### Parameters:

  Name | Type | Argument | Description
  --- | --- | --- | ---
  entity | ModelEntity |  | The entity instance
  scenario | Scenario |  | The scenario to use when formatting the value
  originalValue | string |  | The original value
  key | Array.<*> | optional | The array key for the value, if applicable

  Returns:

  Type | Description
  --- | ---
  string | The formatted value

  ##### Example

      var view = insight.getView();
      var entity = view.getApp().getModelSchema().getEntity(name);
      // Scenario instance is passed in to ScenarioObserver#notify callbacks
      insight.Formatter.getFormattedLabel(entity, scenario, value);

  Back to Top
setEntityFormatter ( entity, formatter )

  Attach a formatting function for a specific entity.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  entity | ModelEntity | string | Either an Insight entity or an entity name
  formatter | function | The formatter function. Callback arguments: {*} value Original value as a primitive data type {Array.<*>} [key] The array key for the value, if applicable Callback return: {*} The formatted value as a primitive type

  ##### Example

      function myFormatFunction(value, key) {
       // process value and return as formatted string.
      }
      insight.Formatter.setEntityFormatter(name, myFormatFunction);

  Back to Top

Parent Topic Classes

© 2001-2026 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.