Initializing help system before first use

Insight

The Insight JavaScript is the main entry point to all Insight functionality from JavaScript

Method summary

name description
addSetSorter Define a sorting function for a set.
getClientType The type of the client that is hosting this view.
getDistribUrl The URL to the Insight distribution folder.
getSetSorter Get the set sorting function for a given set name, if one exists.
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.
removeSetSorter Remove a previously added set sorter.
setDebugEnabled Controls whether log messages are enabled.
setDefaultFormatters Sets default schema defined entity formatters

Methods

method
addSetSorter ( setName, sorter, dimension ) → {boolean}

Define a sorting function for a set. Any previously defined sorting function will be overwritten.

Parameters:
params
Name Type Argument Default Description
setName
type
string
The name of the set
sorter
type
Insight~SortingFunction
The sorting function
dimension
type
insight.enums.EntityDataDimension
optional  insight.enums.EntityDataDimension.NORMAL_DATA The dimension of the set
details
Returns:
returns table
Type Description
type
boolean
Whether the sorter was added or not
Example
examples
insight.addSetSorter('INTEGER_SET', function(orig) {
     // sort the set
     return sorted;
});
Back to Top
method
getClientType ( ) → {insight.enums.ClientType}

The type of the client that is hosting this view.

details
Returns:
returns table
Type Description
type
insight.enums.ClientType
the client type
Example
examples
insight.getClientType(); // returns "Insight Web Client" in web browser.
Back to Top
method
getDistribUrl ( ) → {string}

The URL to the Insight distribution folder.

details
Returns:
returns table
Type Description
type
string
The URL to the Insight distribution folder, including the trailing file separator
Example
examples
insight.getDistribUrl();
Back to Top
method
getSetSorter ( setName, dimension ) → {function|undefined}

Get the set sorting function for a given set name, if one exists.

Parameters:
params
Name Type Argument Default Description
setName
type
string
The name of the set
dimension
type
insight.enums.EntityDataDimension
optional  insight.enums.EntityDataDimension.NORMAL_DATA The dimension of the set
details
Returns:
returns table
Type Description
type
function | undefined
The set sorting function or undefined if one isn't defined
Example
examples
function setSorter(orig) {
     // sort the set
     return sorted;
}
insight.addSetSorter('INTEGER_SET', setSorter);
insight.getSetSorter('INTEGER_SET'); // returns the setSorter function.
Back to Top
method
getView ( ) → {View}

The current Insight View, providing access to the scenarios, project as well as save and reload behaviour.

details
Returns:
returns table
Type Description
type
View
the current View
Example
examples
var view = insight.getView();
Back to Top
method
isDebugEnabled ( ) → {boolean}

Indicates whether log messages and HTML debugging is enabled.

details
Returns:
returns table
Type Description
type
boolean
True if debug is enabled, otherwise false
Example
examples
isDebugEnabled(); // true or false
Back to Top
method
isS3Enabled ( ) → {boolean}

Indicates if S3 has been configured for use

details
Returns:
returns table
Type Description
type
boolean
True if S3 has been configured, otherwise false
Back to Top
method
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'.
  • 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:
params
Name Type Description
viewTitleOrId
type
string
the title or id of the view, as defined in the companion file (or Tableau workbook, as appropriate)
details
Example
examples
insight.openView( 'Welcome' );
Back to Top
method
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 Project entities have been cached. If not completed in 30 seconds then the script will terminate.

Parameters:
params
Name Type Description
callback
type
Insight.readyCallback
A function to execute once the Insight API has initialized.
details
Example
examples
insight.ready(function () {
     // called when the JS API is ready.
     // Add your code here.
});
Back to Top
method
removeSetSorter ( setName, dimension ) → {boolean}

Remove a previously added set sorter.

Parameters:
params
Name Type Argument Default Description
setName
type
string
The name of the set
dimension
type
insight.enums.EntityDataDimension
optional  insight.enums.EntityDataDimension.NORMAL_DATA The dimension of the set
details
Returns:
returns table
Type Description
type
boolean
Whether a sorter was removed or not
Example
examples
function setSorter(orig) {
     // sort the set
     return sorted;
}
insight.addSetSorter('INTEGER_SET', setSorter);
insight.removeSetSorter('INTEGER_SET');
insight.getSetSorter('INTEGER_SET'); // returns undefined.
Back to Top
method
setDebugEnabled ( enabled )

Controls whether log messages are enabled.

Parameters:
params
Name Type Argument Default Description
enabled
type
boolean
optional  true set to true to enable debug, false to disable
details
Example
examples
insight.setDebugEnabled(true); // enable debug logging.
Back to Top
method
setDefaultFormatters ( )

Sets default schema defined entity formatters

details
Back to Top

Type Definitions

method
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().

details
Back to Top
method
SortingFunction ( originalSet ) → {array}

Callback function applied to a set that returns a sorted version of the same set.

Parameters:
params
Name Type Description
originalSet
type
array
The original set
details
Returns:
returns table
Type Description
type
array
The sorted set
Example
examples
function setSorter(originalSet) {
     // Sort the set, for example reverse the order of a set of integers
     return originalSet.sort(function(a,b) {
         return a < b;
     };
}
Back to Top