Insight
Method summary
name | description |
---|---|
addSetComparator | Define a comparator function to be used for sorting a set. Any previously defined comparator function for the set will be replaced with this one. If addSetSorter has also been applied to the same set it will be ignored and this comparator function will be used in preference. |
addSetSorter | Use Insight#addSetComparator instead. |
getClientType | The type of the client that is hosting this view. |
getDistribUrl | The URL to the Insight distribution folder. |
getSetComparator | Get the set comparator function for a given set. |
getSetSorter | Use Insight#getSetComparator instead. |
getVersion | Get the current Insight version. |
getView | Get the current Insight View. |
isDebugEnabled | Indicates whether log messages and HTML debugging is enabled. |
isS3Enabled | Indicates if S3 has been configured for use |
openView | Opens the given custom view. |
ready | Define code to be run once the JS API is loaded and ready. You should wrap your view code in a call to this method. |
removeSetComparator | Remove a previously added set comparator. |
removeSetSorter | Use Insight#removeSetComparator instead. |
resolveRestEndpoint | Get the URL, relative to the server, for a given REST resource or operation. Pass in the REST resource url starting with '/data' or '/auth' for example. |
setDebugEnabled | Controls whether log messages are enabled. |
setDefaultFormatters | Sets default schema defined entity formatters |
Methods
- addSetComparator ( setName, comparator, direction )
-
Define a comparator function to be used for sorting a set. Any previously defined comparator function for the set will be replaced with this one. If addSetSorter has also been applied to the same set it will be ignored and this comparator function will be used in preference.
Parameters:
Name Type Argument Default Description setName string The name of the set comparator Insight~ComparatorFunction | Array.<*> | insight.enums.Comparators The comparator function use to sort the set. Alternatively you can provide an array where the index of a value provides its ordinal number. Also you can provide the name of a built-in comparator from insight.enums.Comparators. direction insight.enums.SortDirection optional insight.enums.SortDirection.ASC If the direction is set to insight.enums.SortDirection.DESC then the sort function will be called with the arguments reversed, sorting the values in the opposite direction Example
Back to Topinsight.addSetComparator('INTEGER_SET', function(a, b) { // Simple number sort return a - b; }, insight.enums.SortDirection.DESC); // Sort days of the week in short form insight.addSetComparator('STRING_SET', ['Mon', 'Tues', 'Wed', 'Thurs', 'Fri', 'Sat', 'Sun']); // Use built-in STRING comparator. This will sort alpha-numeric strings insight.addSetComparator('STRING_SET', insight.enums.Comparators.STRING);
- addSetSorter ( setName, sorter, dimension ) → {boolean}
-
Use Insight#addSetComparator instead.
Parameters:
Name Type Argument Default Description setName string The name of the set sorter Insight~SortingFunction The sorting function dimension insight.enums.EntityDataDimension optional insight.enums.EntityDataDimension.NORMAL_DATA The dimension of the set - Deprecated since Js Api 4.7
Returns:Type Description boolean Whether the sorter was added or not - getClientType ( ) → {insight.enums.ClientType}
-
The type of the client that is hosting this view.
Returns:Type Description insight.enums.ClientType the client type Example
Back to Topinsight.getClientType(); // returns "Insight Web Client" in web browser.
- getDistribUrl ( ) → {string}
-
The URL to the Insight distribution folder.
Returns:Type Description string The URL to the Insight distribution folder, including the trailing file separator Example
Back to Topinsight.getDistribUrl();
- getSetComparator ( setName ) → {Object.<{comparator: (Insight~ComparatorFunction|Array.<*>), direction: insight.enums.SortDirection}>|undefined}
-
Get the set comparator function for a given set.
Parameters:
Name Type Description setName string The name of the set Returns:Type Description Object.<{comparator: (Insight~ComparatorFunction|Array.<*>), direction: insight.enums.SortDirection}> | undefined The comparator function/array and sort direction, if any assigned to the set. - getSetSorter ( setName, dimension ) → {function|undefined}
-
Use Insight#getSetComparator instead.
Parameters:
Name Type Argument Default Description setName string The name of the set dimension insight.enums.EntityDataDimension optional insight.enums.EntityDataDimension.NORMAL_DATA The dimension of the set - Deprecated since Js Api 4.7
Returns:Type Description function | undefined The set sorting function or undefined if one isn't defined - getVersion ( ) → {Version}
-
Returns the current Insight version as an object or using the built-in toString.
Returns:Type Description Version Example
Back to Topvar version = insight.getVersion();
- getView ( ) → {View}
-
The current Insight View, providing access to the scenarios, app as well as save and reload behaviour.
Returns:Type Description View the current View Example
Back to Topvar view = insight.getView();
- isDebugEnabled ( ) → {boolean}
-
Indicates whether log messages and HTML debugging is enabled.
Returns:Type Description boolean True if debug is enabled, otherwise false Example
Back to TopisDebugEnabled(); // true or false
- isS3Enabled ( ) → {boolean}
-
Indicates if S3 has been configured for use
Returns:Type Description boolean True if S3 has been configured, otherwise false - openView ( viewTitleOrId )
-
Opens the given custom view. In the Analyst Client, the view is opened in a new tab. In the web client, the new view is opened in the current window. The view to be opened can be identified in a variety of ways:
- Non-Tableau views
- The title of the view, as specified using the
title
attribute in the companion file. If there are several views with the same title, the first will be chosen. - The id of the view, as specified using the optional
id
attribute in the companion file. - The title of the view group and title of the view, separated by two colons, e.g. 'My Group::My View'.
- The title of the view, as specified using the
- Tableau views (which do not directly have have entries in the companion file)
- The title of the Tableau view
- The title of the view group and title of the Tableau view, separated by two colons, e.g. 'My Group::My View'.
Parameters:
Name Type Description viewTitleOrId string the title or id of the view, as defined in the companion file (or Tableau workbook, as appropriate) Example
Back to Topinsight.openView( 'Welcome' );
- Non-Tableau views
- ready ( callback )
-
Define code to be run once the JS API is loaded and ready. You should wrap all your view code within a call to this method.
This function will execute the callback once the Model Schema and App entities have been cached. If not completed in 30 seconds then the script will terminate.Parameters:
Name Type Description callback Insight.readyCallback A function to execute once the Insight API has initialized. Example
Back to Topinsight.ready(function () { // called when the JS API is ready. // Add your code here. });
- removeSetComparator ( setName )
-
Remove a previously added set comparator.
Parameters:
Name Type Description setName string The name of the set - removeSetSorter ( setName, dimension ) → {boolean}
-
Use Insight#removeSetComparator instead.
Parameters:
Name Type Argument Default Description setName string The name of the set dimension insight.enums.EntityDataDimension optional insight.enums.EntityDataDimension.NORMAL_DATA The dimension of the set - Deprecated since Js Api 4.7
Returns:Type Description boolean Whether a sorter was removed or not - resolveRestEndpoint ( restResource ) → {string}
-
Get the URL, relative to the server, for a given REST resource or operation. Pass in the REST resource url starting with '/data' or '/auth' for example.
Parameters:
Name Type Description restResource string The REST resource url. Must contain a leading slash, for example "/data/scenario" Returns:Type Description string The resolved REST endpoint URL that can be used to pass into a request Example
Back to Top// List apps var appsUrl = insight.resolveRestEndpoint('/data/project'); fetch(appsUrl).then(function(response) { return response.json(); }) .then(function(response) { console.log(response.items); });
- setDebugEnabled ( enabled )
-
Controls whether log messages are enabled.
Parameters:
Name Type Argument Default Description enabled boolean optional true set to true to enable debug, false to disable Example
Back to Topinsight.setDebugEnabled(true); // enable debug logging.
- setDefaultFormatters ( )
-
Sets default schema defined entity formatters
Type Definitions
- readyCallback ( )
-
Invoked when the JS API is ready to be used. You should wrap your view code in a callback and pass it to
insight.ready()
. - ComparatorFunction ( a, b ) → {number}
-
A comparator function applied to a set.
Parameters:
Name Type Description a Value to compare b Value to compare Returns:Type Description number Return less than 0 if 'a' should come before 'b' in ascending order, 0 if 'a' and 'b' are equal and greater than 0 if 'b' should come before 'a' in ascending order. Example
Back to Topfunction setComparator(a, b) { // Simple number sort return a - b; }
- SortingFunction ( originalSet ) → {array}
-
Use Insight~ComparatorFunction instead.
Parameters:
Name Type Description originalSet array The original set - Deprecated since Js Api 4.7
Returns:Type Description array The sorted set
© 2001-2023 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.