Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Publisher Abstract

Hierarchy

  • Publisher

Index

Coloring

Column

Data table

Event

Filter

JSON to data table

Key value pairs

Marking

Other

Renderer

Row

Spotfire UI

Tag column

Util

Value group

Coloring

  • Fetches the coloring information for the active data table.

    example

    Fetch the coloring.

    try {
    const response = await publisher.fetchColoring();
    console.log('fetchColoring response', response);
    } catch (error) {
    console.log('Error fetching coloring', error);
    }
    throws

    Error

    Returns Promise<ColoringResponse>

    a promise providing the coloring information for the active data table.

  • Fetches the colors for a list of values (or single value) using the coloring rules for a column.

    example

    Fetches the colors for the provided list of values using the color rules defined on the provided column.

    try {
    const response = await publisher.fetchColorsForValues({
    column: 'da97779c-75a5-48cc-a75d-d4d3ef4bac96iColumn 1',
    values: [10.0, 25.0, -5]
    });
    console.log('fetchColorsForValues response', response);
    } catch (error) {
    console.log('Error fetching colors for values', error);
    }
    throws

    Error

    Parameters

    Returns Promise<ColorsForValuesResponse>

    a promise providing the colors for the provided values.

  • Updates the coloring being used for the active data table.

    remarks

    This can be used in one of three ways:

    The first is where an array of colorings is provided that will replace the current matching colorings based on the columns to which they are applied.

    example

    Replace a single coloring.

    try {
    await publisher.setColoring({
    coloring: [
    {
    dataTable: 'da97779c-75a5-48cc-a75d-d4d3ef4bac96',
    displayName: 'AVG LOG IC50',
    columnNames: ['AVG LOG IC50'],
    dataType: SpotfireDataType.REAL,
    rules: [
    {
    type: ColorType.RANGE,
    ruleType: RuleType.GRADIENT,
    scalePerColumn: true,
    breakpoints: [
    {
    value: 0,
    color: '#2E6072',
    columnValueType: ColumnValueType.MAX,
    },
    {
    value: 0,
    color: '#E0EAF3',
    columnValueType: ColumnValueType.MIN,
    },
    ],
    } as RangeRule,
    {
    type: ColorType.FIXED,
    color: "#FFFFFF",
    ruleType: RuleType.EMPTY,
    } as FixedRule,
    ],
    },
    ]
    });
    } catch (error) {
    console.log('Error setting coloring', error);
    }

    The second is where the colorings from the current visual will be applied to one or more target Publisher/ChemCharts visuals. A list of visuals can be obtained using Publisher.fetchVisuals.

    example

    Set the coloring from the current visual on to a couple of target visuals.

    try {
    await publisher.setColoring({ target: ['targetVisualId1', 'targetVisualId2'] });
    } catch (error) {
    console.log('Error setting coloring', error);
    }

    The third is where the coloring from a source Publisher/ChemCharts visual will be applied to the current visual. A list of visuals can be obtained using Publisher.fetchVisuals.

    example

    Set the coloring on the current visual from a source Publisher/ChemCharts visual.

    try {
    await publisher.setColoring({ source: ['sourceVisualId'] });
    } catch (error) {
    console.log('Error setting coloring', error);
    }
    throws

    Error

    Parameters

    Returns Promise<void>

    promise that resolves after the coloring has been set

Column

  • Adds a calculated column to the active data table.

    example

    Add a simple calculated column.

    try {
    await publisher.addCalculatedColumn({
    name: 'Calculated column',
    expression: 'case when ([Evalue] >= 3.63673472) then 1 else 0 end',
    });
    } catch (error) {
    console.log('Error adding calculated column', error);
    }
    throws

    Error

    Parameters

    Returns Promise<DataTableColumn>

    promise that resolves after adding the calculated column

  • addColumns(request: { columns: string[] }): Promise<void>
  • Adds the columns with the provided IDs into the columns array in the ActiveConfiguration, such that they are now 'configured'.

    remarks

    They columns will now appear in the columns array in the ActiveConfiguration and they will not appear in the unconfiguredColumns array. If columns are not defined in a fetchRows request, data will only be selected for the configured columns. This does not create new columns.

    example

    Adds the 2 columns with the provided IDs into the active configuration columns array.

    try {
    await publisher.addColumns({
    columns: ['da97779c-75a5-48cc-a75d-d4d3ef4bac96iColumn 1', 'da97779c-75a5-48cc-a75d-d4d3ef4bac96iColumn 2'],
    });
    } catch (error) {
    console.log('Error configuring columns', error);
    }
    throws

    Error

    deprecated

    will be removed in Publisher 4.1

    Parameters

    • request: { columns: string[] }

      object containing an array of column IDs

      • columns: string[]

    Returns Promise<void>

    promise that resolves after adding columns into columns array in the ActiveConfiguration

  • Fetches a range of population statistics for the columns defined in the FetchColumnStatsRequest object.

    example

    Fetch the full range of population statistics for the provided column only including rows after filtering.

    try {
    const response = await publisher.fetchColumnStats({
    propColumns: [{ id: 'da97779c-75a5-48cc-a75d-d4d3ef4bac96iColumn 1', log: false }],
    rows: 'filtered',
    });
    console.log('response', response);
    } catch (error) {
    console.log('Error fetching column statistics', error);
    }
    throws

    Error

    Parameters

    Returns Promise<FetchColumnStatsResponse>

    a promise providing the column stats for the requested columns

  • Fetches the list of columns for the data table with the provided ID.

    example

    Fetch columns for a given data table and include column properties.

    try {
    const response = await publisher.fetchColumns({ id: 'ba5567af-f353-4acb-88b2-8acafcb6851e', properties: true });
    console.log('response', response);
    } catch (error) {
    console.log('Error fetching columns', error);
    }
    throws

    Error

    Parameters

    Returns Promise<FetchColumnsResponse>

    a promise providing the columns for the requested data table

  • fetchFilteredColumns(): Promise<{ filteredColumns: string[] }>
  • Returns the column IDs for columns that have a filter on them for the active data table.

    example

    Fetch the column IDs for columns that have filters on them for the active data table.

    try {
    const response = await publisher.fetchFilteredColumns();
    console.log('response', response);
    } catch (error) {
    console.log('Error fetching filtered columns', error);
    }
    throws

    Error

    Returns Promise<{ filteredColumns: string[] }>

    a promise providing the column IDs for the filtered columns

  • Returns the unique values for each of the provided columns.

    remarks

    The array of uniques values for each column are always returned as strings, regardless of the data type of the column.

    example

    Fetch the unique values for a single column.

    try {
    const response = await publisher.fetchUniqueValues({ columns: ['ba5567af-f353-4acb-88b2-8acafcb6851esCode'] });
    console.log('response', response);
    } catch (error) {
    console.log('Error fetching unique values', error);
    }
    example

    Page through the first 100 unique values for a single column.

    try {
    const response = await publisher.fetchUniqueValues({
    columns: ['ba5567af-f353-4acb-88b2-8acafcb6851esCode'],
    from: 0,
    count: 100,
    });
    console.log('response', response);
    } catch (error) {
    console.log('Error fetching unique values', error);
    }
    throws

    Error

    Parameters

    Returns Promise<UniqueColumnValuesResponse>

    a promise that once resolved provides an array of unique values for each of the columns in the request.

  • removeColumns(request: { columns: string[]; delete?: boolean }): Promise<void>
  • Removes the columns with the provided column IDs from the columns array in the ActiveConfiguration such that they are now unconfigured. Setting the optional {@link request#delete} argument to true will actually delete the columns from the data table instead of unconfiguring them.

    remarks

    The columns will not be in the columns array in the ActiveConfiguration and they will be in the unconfiguredColumns array. If columns are not defined in a Publisher.fetchRows request, data will only be selected for the configured columns. This does not delete columns from the active data table unless the request.delete argument is set to true.

    example

    Removes the 2 columns with the IDs from the active configuration column array.

    try {
    await publisher.removeColumns({
    columns: [
    'da97779c-75a5-48cc-a75d-d4d3ef4bac96iColumn 1',
    'da97779c-75a5-48cc-a75d-d4d3ef4bac96iColumn 2'],
    });
    } catch (error) {
    console.log('Error configuring columns', error);
    }
    throws

    Error

    deprecated

    will be removed in Publisher 4.1

    Parameters

    • request: { columns: string[]; delete?: boolean }

      object containing an array of column IDs

      • columns: string[]
      • Optional delete?: boolean

    Returns Promise<void>

    promise that resolves after the columns have been removed from the ActiveConfiguration

  • reorderColumns(request: { columns: string[] }): Promise<void>
  • Reorders the columns in the active data table given the ordered array of column IDs.

    example

    Reorder the columns.

    try {
    await publisher.reorderColumns({
    columns: [
    'da97779c-75a5-48cc-a75d-d4d3ef4bac96iColumn 1',
    'da97779c-75a5-48cc-a75d-d4d3ef4bac96iColumn 2',
    'da97779c-75a5-48cc-a75d-d4d3ef4bac96iColumn 3',
    ],
    });
    } catch (error) {
    console.log('Error reordering columns', error);
    }
    throws

    Error

    deprecated

    will be removed in Publisher 4.1

    Parameters

    • request: { columns: string[] }

      object containing array of ordered column IDs

      • columns: string[]

    Returns Promise<void>

    promise that resolves after the columns have been reordered

  • Updates the calculated column with the provided ID with a new expression.

    example

    Update the expression on a calculated column.

    try {
    await publisher.updateCalculatedColumn({
    id: 'da97779c-75a5-48cc-a75d-d4d3ef4bac96iColumn 1',
    expression: 'case when ([Other column] >= 4) then 1 else 0 end',
    });
    } catch (error) {
    console.log('Error updating calculated column', error);
    }
    throws

    Error

    Parameters

    Returns Promise<DataTableColumn>

    promise that resolves once the calculated column has been updated

Data table

  • Fetches the active configuration that contains details about the active data table (e.g. columns, number of rows, marking configuration, sorting etc.). Row data will be returned if the request includes the optional from and count or rows parameters e.g.

    example

    Fetch the active configuration (no rows, include columns).

    try {
    const activeConfiguration = await publisher.fetchActiveConfiguration();
    console.log(activeConfiguration);
    } catch (error) {
    console.log('Error fetching active configuration', error);
    }
    example

    Fetch the active configuration. Include the first 10 rows in the view after filtering and sorting. Exclude columns.

    try {
    const activeConfiguration =
    await publisher.fetchActiveConfiguration({ from: 0, count: 10, includeColumns: false });
    console.log(activeConfiguration);
    } catch (error) {
    console.log('Error fetching active configuration', error);
    }
    example

    Fetch the active configuration with 5 rows using table row indexes (before sorting or filtering). This wlll include columns.

    try {
    const activeConfiguration = await publisher.fetchActiveConfiguration({ rows: [3, 45, 56, 84, 100] });
    console.log(activeConfiguration);
    } catch (error) {
    console.log('Error fetching active configuration', error);
    }
    throws

    Error

    Parameters

    Returns Promise<ActiveConfiguration>

    promise providing the active configuration

  • Fetches a list of the data tables in the document.

    example

    Fetch the data tables (the properties will be returned as the default is true if the properties argument is omitted).

    try {
    const response = await publisher.fetchDataTables();
    console.log('data tables', response.tables);
    } catch (error) {
    console.log('Error fetching data tables', error);
    }
    throws

    Error

    Parameters

    • Optional request: { properties?: boolean }

      object containing parameters for fetching data tables

      • Optional properties?: boolean

        whether to include the properties for each of the data tables. The default is false if not defined.

    Returns Promise<DataTablesResponse>

    a promise providing the array of data tables

  • Performs a text search 'find' operation using the provided pattern or regular expression on the active data table and returns the next match location.

    The response from the endpoint contains location information about the match, see FindResponse. The returned information can be used to form the next find query, where the start location of the next 'find' can be set to the location of the previous.

    By default the string comparisons are case insensitive substrings. Regular expressions can be used instead using request.regexp.

    Multi-line queries are also possible using request.multiline.

    If the request.markRows is set to true all rows that match the provided query will be marked.

    example

    Find the first case insesitive match for the string 'cat' in the active data table after filtering and sorting, then find the next instance of a match.

    try {
    let response = await publisher.find({
    pattern: 'cat',
    rows: 'filtered',
    });
    if (response.vdx !== -1) {
    console.log('first match', response);
    // Found a match!
    // Let's find the next match by starting from the
    // location returned from the previous find operation.
    response = await publisher.find({
    pattern: 'cat',
    rows: 'filtered',
    startColumn: response.column,
    vdx: response.vdx,
    });
    console.log('second match', response);
    } else {
    console.log('No matches');
    }
    } catch (error) {
    console.log('Error performing find', error);
    }
    throws

    Error

    Parameters

    Returns Promise<FindResponse>

    a promise that provides the positional details of the next match

  • Sets the active data table for the visual.

    example

    Set the active data table using the name.

    try {
    await publisher.setActiveDataTable({ name: 'Data table name' });
    } catch (error) {
    console.log('Error setting active data table', error);
    }
    example

    Set the active data table using the ID.

    try {
    await publisher.setActiveDataTable({ id: '6a9339b0-313c-4aab-92ec-6b00e8451bc8' });
    } catch (error) {
    console.log('Error setting active data table', error);
    }
    throws

    Error

    Parameters

    Returns Promise<void>

    a promise that resolves after the active data table has been set

  • Sets the sorting criteria used to sort the active data table.

    example

    Sort by 2 columns.

    try {
    await publisher.sort([
    { id: '6a9339b0-313c-4aab-92ec-6b00e8451bc8iHAC', order: 'ascending' },
    { id: '6a9339b0-313c-4aab-92ec-6b00e8451bc8iMW', order: 'descending' },
    ]);
    } catch (error) {
    console.log('Error sorting', error);
    }
    throws

    Error

    Parameters

    Returns Promise<void>

    promise that resolves once sorting is complete

Event

Filter

  • Fetches the filters. The response contains an an array of objects, each of which defines the current filtering (if any) that is applied to a given column. The filters returned depends on the properties of the request parameter.

    example

    Fetch all filters for the document.

    try {
    const response = await publisher.fetchFilters();
    console.log('fetchFilters response', response);
    } catch (error) {
    console.log('Error fetching filters', error);
    }
    example

    Fetch filters for the active data table for a subset of columns.

    try {
    const response = await publisher.fetchFilters({
    dataTable: 'active',
    columns: ['da97779c-75a5-48cc-a75d-d4d3ef4bac96iColumn 1', 'da97779c-75a5-48cc-a75d-d4d3ef4bac96iColumn 2'],
    });
    console.log('fetchFilters response', response);
    } catch (error) {
    console.log('Error fetching filters', error);
    }
    example

    Fetch all filters for a specified data table.

    try {
    const response = await publisher.fetchFilters({
    dataTable: 'da97779c-75a5-48cc-a75d-d4d3ef4bac96',
    });
    console.log('fetchFilters response', response);
    } catch (error) {
    console.log('Error fetching filters', error);
    }
    throws

    Error

    Parameters

    • Optional request: FiltersRequest

      the request objects defining which filters to retrieve

    Returns Promise<FiltersResponse>

    a promise providing the array of filters

  • setFilters(request: { filters?: Filter[]; reset?: "all" | "active" }): Promise<void>
  • Replaces the filters on the document with the provided array of filters. Note that each of the filters must be of the same type as the filter currently on the column.

    example

    Update the filter in this example it is a range filter on a numeric column. The low bound for the value is not set by using the 'min' constant, the high bound is set to 100.

    try {
    await publisher.setFilters({
    filters: [
    {
    values: {
    low: 'min',
    high: 100,
    },
    includeEmpty: true,
    name: 'PSA',
    id: '04ce21bf-9360-46cd-9ef5-58ed41d0606frPSA',
    type: 'range',
    modified: false,
    hasEmptyValues: false,
    }
    ],
    });
    } catch (error) {
    console.log('Error updating filters', error);
    }
    throws

    Error

    Parameters

    • request: { filters?: Filter[]; reset?: "all" | "active" }

      object containing the array of filter objects

      • Optional filters?: Filter[]
      • Optional reset?: "all" | "active"

    Returns Promise<void>

    promise that resolves after the filtering has been set

  • Filters the active data to include or excelude rows in one of two ways:

    1. Using provided row idxs.
    2. If the optional valueGroup argument is present, this filters the active data table to include or exclude rows that contain the distinct value exemplified by each of the provided row idxs for the provided value group. This requires a column assignment for the value group.
    example

    Filter the active data table to only show rows with the provided idxs.

    try {
    await publisher.setRowIndexFilter({ rows: [6, 24, 30], state: 'include' });
    } catch (error) {
    console.log('Error setting row index filter', error);
    }
    example
    try {
    await publisher.setRowIndexFilter({ rows: [12], state: 'include', valueGroup: 'valueGroup1' });
    } catch (error) {
    console.log('Error setting row index filter', error);
    }
    throws

    Error

    Parameters

    Returns Promise<void>

    promise that resolves after row index filter has been set

JSON to data table

  • Adds new columns and data to the target data table.

    throws

    Error

    Parameters

    Returns Promise<void>

    a promise that resolves after adding the data to the target data table

  • Adds new columns and data to the target data table. This adds data from a JSON file served up from a URI.

    throws

    Error

    Parameters

    Returns Promise<void>

    a promise that resolves after adding the data to the target data table

  • Adds a set of rows to the target data table.

    throws

    Error

    Parameters

    • request: AddRowsRequest

      object defining the rows to add and the target data table

    Returns Promise<void>

    a promise that resolves after adding the data to the target data table

  • Adds new rows to the target data table. This adds data from a JSON file served up from a URI.

    throws

    Error

    Parameters

    Returns Promise<void>

    a promise that resolves after adding the data to the target data table

  • Create a new data table from the provided data.

    example

    Creates a simple table containig 2 columns ('Column 1' and 'Column 2'). The first columns contains strings, the second contains floating point values. The data table is called 'My new table'.

    const request = {
    columns: [
    {
    name: 'Column 1',
    dataType: 'string',
    },
    {
    name: 'Column 2',
    dataType: 'double',
    },
    ],
    data: [
    [ 'Dog', 28.2 ],
    [ 'Cat', 32.2 ],
    ],
    table: {
    name: 'My new table',
    },
    }
    try {
    await publisher.createDataTableFromJson(request);
    } catch (error) {
    console.log('Error creating data table from json', error);
    }
    throws

    Error

    Parameters

    Returns Promise<CreateDataTableResponse>

    a promise that resolves after the data table has been created

  • Create a new data table by adding data from a JSON file served up from a URI.

    throws

    Error

    Parameters

    Returns Promise<CreateDataTableResponse>

    a promise that resolves after the data table has been created

  • Returns the current data table in a JSON format suitable for posting to webservices. The rows are retrieved after filtering and sorting.

    throws

    Error

    Parameters

    • request: { count: number; from: number }

      options for row retrieval

      • count: number

        the number of rows to retrieve

      • from: number

        the from index for row retrieval

    Returns Promise<TableToJsonResponse>

    promise that resolves to provide the data table

Key value pairs

  • clearKeyValuePairs(): Promise<void>
  • Removes all the key value pairs from the key value pair store on the active visual.

    example
    try {
    await publisher.clearKeyValuePairs();
    } catch (error) {
    console.log('Error clearing key value pairs', error);
    }
    throws

    Error

    Returns Promise<void>

    a promise that resolves after clearing the key value pairs

  • Fetches the key value pairs store containing a set of key value pairs (both must strings). Key value pairs can be modified using setKeyValuePairs and clearKeyValuePairs.

    example

    Fetch key value pairs.

    try {
    const response = await publisher.fetchKeyValuePairs();
    for (var key in response) {
    console.log(key, response[key]);
    }
    } catch (error) {
    console.log('Error fetching key value pairs', error);
    }
    throws

    Error

    Returns Promise<KeyValuePairs>

    a promise providing the key value pairs

  • Adds or replaces the key value pairs in the key value pair store with the key value pairs in the provided request object. The keys and values in the object parameter must be strings.

    example

    Add or replace the key value pairs with the keys 'color' and 'included'. Note the 'included' value is a string as all keys and values in the key value pair store must be strings.

    try {
    await publisher.setKeyValuePairs({ color: 'red', included: 'true' });
    } catch (error) {
    console.log('Error setting key value pairs', error);
    }
    throws

    Error

    Parameters

    • request: KeyValuePairs

      object containing one or more key value pairs. The keys and values must be strings.

    Returns Promise<void>

    a promise that resolves after the key value pairs have updated

Marking

  • Fetches the current marking configuration for the document.

    throws

    Error

    Returns Promise<MarkingConfiguration>

    a promise that conttrains the current set of marking configurations once resolved

  • limitByMarking(enabled: boolean): Promise<void>
  • Configure a 'limit' chart i.e. a chart that is limited by the current marking, but does not display rows as being marked.

    example

    Enable limit by marking.

    try {
    await publisher.limitByMarking(true);
    } catch (error) {
    console.log('Error setting limit by marking', error);
    }
    throws

    Error

    Parameters

    • enabled: boolean

      whether limit by marking is enabled or not

    Returns Promise<void>

    a promise that resolves after limit by marking has been enabled/disabled

  • Modifies the row markings.

    example

    Add (i.e. mark) the rows with the provided idxs to the marking.

    try {
    await publisher.markRows({ rows: [0, 2, 5, 8], mode: MarkRowsMode.ADD });
    } catch (error) {
    console.log('Error marking rows', error);
    }
    example

    Subtract (i.e. unmark) 10 rows from visible index 12 to the marking.

    try {
    await publisher.markRows({ from: 12, count: 10, mode: MarkRowsMode.SUBTRACT });
    } catch (error) {
    console.log('Error marking rows', error);
    }
    throws

    Error

    Parameters

    Returns Promise<void>

    promise that resolves after the script has been successfully started

  • Sets the marking to be used in the current visualization.

    example

    Set the current marking 'my marking' to be the marking used for the current visual.

    try {
    await publisher.setMarking({ name: 'my marking' });
    } catch (error) {
    console.log('Error setting marking', error);
    }
    throws

    Error

    Parameters

    Returns Promise<void>

    a promise that is resolved after the marking has been set

Other

  • Used to copy one of the following to the system clipboard:

    • The value for a given cell in a row from a data table.
    • One or more rows from a data table (as tab delimited text).
    • Image data
    remarks

    This does not work in the WebPlayer.

    example

    Copy a value in a cell in a row to the clipboard.

    try {
    await publisher.copyToClipboard({ column: 'ba5567af-f353-4acb-88b2-8acafcb6851eiCode', idx: 0 });
    } catch (error) {
    log.error('Error copying to clipboard', error);
    }
    example

    Copy an array of rows to the clipboard.

    try {
    await publisher.copyToClipboard({ rows: [0, 1, 2] });
    } catch (error) {
    log.error('Error copying to clipboard', error);
    }
    example

    Copy an image to the clipboard, rovide the base64 encoded string and the format.

    try {
    await publisher.copyToClipboard({ data: <base64 encoded png>, format: 'image/png' });
    } catch (error) {
    log.error('Error copying to clipboard', error);
    }
    throws

    Error

    Parameters

    Returns Promise<void>

    promise that resolves after the data has been set on the clipboard

  • Executes the provided IronPython script. Note that the promise from the endpoint will often resolve before the IronPython has finished executing (i.e. the IronPython script is executed asynchronously). It is possible to listen for script lifecycle events by adding a script execution listener to publisher, see PublisherEventType.SCRIPT_EXECUTION.

    example

    Execute a simple IronPython script.

    try {
    const data = {
    script: 'print("Hello {}".format(arg1))',
    args: {
    arg1: 'from IronPython-land',
    },
    };
    await publisher.executeScript(data);
    } catch (error) {
    console.log('Error executing iron python', error);
    }
    throws

    Error

    Parameters

    Returns Promise<void>

    promise that resolves after the script has been successfully started

  • fetchClipboardContents(request: { keys?: string[] }): Promise<{}>
  • Fetches the contents of the system clipboard. This does not work in the WebPlayer.

    example

    Fetch all clipboard contents.

    try {
    const response = await publisher.fetchClipboardContents();
    console.log('Clipboard contents', response);
    } catch (error) {
    console.log('Error fetching clipboard contents', error);
    }
    throws

    Error

    Parameters

    • request: { keys?: string[] }

      object containing parameters for getting the clipboard contents

      • Optional keys?: string[]

        optionally restrict returned clipboard contents to specific keys

    Returns Promise<{}>

    promise that provides the contents of the clipboard

  • fetchPreferences(): Promise<{}>
  • Fetches the preferences. These are the preferences that are configured in Tools -> Administration manager -> Preferences tab

    example

    Fetch the preferences.

    try {
    const response = await publisher.fetchPreferences();
    console.log('Preferences', response);
    } catch (error) {
    console.log('Error fetching preferences', error);
    }
    throws

    Error

    Returns Promise<{}>

    a promise providing the preferences

  • Fetches the document, data table or column properties. Properties are stored on this objects as name/value pairs.

    example

    Fetch some document properties that have names 'Dog' and 'Cat'.

    try {
    const response = await publisher.fetchProperty({
    name: ['Dog', 'Cat'],
    propertyClass: 'document',
    });
    console.log('Properties', response);
    } catch (error) {
    console.log('Error fetching document properties', error);
    }
    example

    Fetch some data table properties that have names 'Dog' and 'Cat'.

    try {
    const response = await publisher.fetchProperty({
    id: 'ba5567af-f353-4acb-88b2-8acafcb6851e',
    name: ['Dog', 'Cat'],
    propertyClass: 'table',
    });
    console.log('Properties', response);
    } catch (error) {
    console.log('Error fetching data table properties', error);
    }
    throws

    Error

    Parameters

    Returns Promise<{}>

    a promise proving the properties

  • fetchRuntimeProperties(): Promise<{}>
  • Returns the runtime properties associated with the visual.

    throws

    Error

    Returns Promise<{}>

    a promise providing the runtime properties

  • fetchStaticCdjsAddress(): Promise<undefined | string>
  • Returns the static file server address for CDJS resources

    Returns Promise<undefined | string>

    Promise that resolves to resource URL

  • fetchStaticResourceAddress(): Promise<undefined | string>
  • Returns the static file server address for Charts resources

    Returns Promise<undefined | string>

    Promise that resolves to resource URL

  • fetchUser(): Promise<User>
  • Fetches the currently logged in user details.

    example

    Get the user information.

    try {
    const user = await publisher.fetchUser();
    console.log('Username', user.username, ' identity', user.identity);
    } catch (error) {
    console.log('Error fetching renderers', error);
    }
    throws

    Error

    Returns Promise<User>

    promise that provides an object with the user details

  • Submits an http request through .NET via Publisher. This method can be used to avoid CORS issues.

    example

    Hit an example webservice to fetch a molecule given an ID.

    try {
    const params = {
    uri: 'http://get-my-molecule',
    json: { id: 12 },
    contentType: 'application/json',
    type: 'POST',
    };
    const response = await publisher.httpRequest(params);
    console.log('response', response);
    } catch (error) {
    console.log('Error', error);
    }
    throws

    Error

    deprecated

    replaced with Publisher.restRequest

    Parameters

    • request: HttpRequestData

      object containing the various settings for the http request.

    Returns Promise<HttpRequestResponse>

    a promise that provides an object containing the result of the http request.

  • mutableDiscard(): Promise<{ discarded: boolean }>
  • Returns Promise<{ discarded: boolean }>

  • Submits an http rest request through .NET via Publisher. This method can be used to avoid CORS issues.

    example

    Hit an example URL and retrieve the response.

    try {
    const request = {
    uri: 'http://example-url.com',
    type: HttpMethod.GET,
    };
    const response = await publisher.restRequest(request);
    console.log('response', response);
    } catch (error) {
    console.log('Error', error);
    }
    example

    Post JSON to a web service. Added the header record to indicate we are posting JSON. The JSON is posted via the 'body' parameter.

    try {
    const objectToPost = {
    cat: 'Purr',
    dog: 'Woof',
    };
    const request = {
    method: HttpMethod.POST,
    uri: 'http://post-some-json.com',
    headers: [
    { name: 'content-type', value: 'application/json' },
    ],
    parameters: [
    { name: 'body', value: objectToPost, type: RestRequestParameterType.REQUEST_BODY },
    ],
    };
    const response = await publisher.restRequest(request);
    console.log('response', response);
    } catch (error) {
    console.log('Error', error);
    }
    throws

    Error

    Parameters

    • request: RestRequest

      object containing the various settings for the rest request.

    Returns Promise<RestResponse>

    a promise that provides an object containing the result of the rest request.

  • setHttps(https: boolean): void
  • If serving an app via https, set this to true in order to avoid browser complaining about mixed http/https requests.

    Parameters

    • https: boolean

      whether you are using https in your app.

    Returns void

  • Sets a property (defined by the propertyClass) on the document, a data table or a column e.g.

    example

    Set a document property

    try {
    await publisher.setProperty({
    dataType: SpotfireDataType.STRING,
    name: 'animal',
    propertyClass: 'document',
    value: 'cat',
    } catch (error) {
    console.log('Error setting document property', error);
    }
    example

    Set a column property

    try {
    await publisher.setProperty({
    dataType: SpotfireDataType.STRING,
    id: 'ba5567af-f353-4acb-88b2-8acafcb6851esCode',
    name: 'AnimalSound',
    propertyClass: 'column',
    value: 'Cat goes purr',
    } catch (error) {
    console.log('Error setting column property', error);
    }
    throws

    Error

    Parameters

    Returns Promise<void>

    a promise that resolves after the properties have been updated

  • setRuntimeProperties(request: {}): Promise<void>
  • Set one or more properties that exist as long as the visual. These properties are not saved.

    throws

    Error

    Parameters

    • request: {}

      object containing properties

      • [s: string]: number | string | boolean

    Returns Promise<void>

    a promise that resolves once the properties have been set

  • Converts the active data table to excel.

    throws

    Error

    Parameters

    Returns Promise<TableToExcelResponse>

    promise that resolves after setting the visual configuration

Renderer

  • Fetches an image for a given cell in a data table. The cell is defined by the unique column identifier and the row index. For the request to succeed, a Publisher cell renderer that produces an image must be assigned for the referenced column, see Publisher.setRenderers.

    example

    Generate the image for the row with idx = 77 for the column with id = 'ba5567af-f353-4acb-88b2-8acafcb6851esMolecule'.

     try {
    const response = await publisher.fetchCellImage({
    id: 'ba5567af-f353-4acb-88b2-8acafcb6851esMolecule',
    row: 77,
    format:'svg',
    width: 200,
    height: 200
    });
    console.log('response', response);
    } catch (error) {
    console.log('Error fetching image for cell', error);
    }
    throws

    Error

    Parameters

    • data: FetchCellImageData

      defines the row, column for which to generate the image as well as image parameters

    Returns Promise<CellImageData | { images: CellImageData[] }>

    promise providing the image data for the cell

  • fetchRenderers(request: { column?: string; columns?: string[] }): Promise<RenderersResponse>
  • Returns information about the possible renderers and the currently configured renderer for the indicated columns.

    example

    Fetch renderer information for the 2 columns indicated.

    try {
    const response = await publisher.fetchRenderers({
    columns: [
    'ba5567af-f353-4acb-88b2-8acafcb6851esCode',
    'ba5567af-f353-4acb-88b2-8acafcb6851esMolecule',
    ],
    });
    console.log('Response', response);
    } catch (error) {
    console.log('Error fetching renderers', error);
    }
    throws

    Error

    Parameters

    • request: { column?: string; columns?: string[] }

      object indicating which columns to retrieve renderers for

      • Optional column?: string

        single column ID

      • Optional columns?: string[]

        array of column IDs

    Returns Promise<RenderersResponse>

    a promise that provides information for the possible renderers and currently configured renderer for the indicated columns

  • Sets the renderers for the indicated columns.

    example

    Set the renderers for 2 columns.

    try {
    await publisher.setRenderers({
    columns: [
    { 'ba5567af-f353-4acb-88b2-8acafcb6851esCode': RendererName.TEXT },
    { 'ba5567af-f353-4acb-88b2-8acafcb6851esURL': RendererName.LINK },
    ],
    });
    } catch (error) {
    log.error('Error setting renderer', error);
    }
    example

    Set the renderers for a column with options defined.

    try {
    await publisher.setRenderers({
    columns: [{
    id: 'ba5567af-f353-4acb-88b2-8acafcb6851esCode',
    options: { option1: 'dog', option2: 'cat' },
    renderer: RendererName.TEXT,
    }],
    });
    } catch (error) {
    log.error('Error setting renderer', error);
    }
    throws

    Error

    Parameters

    Returns Promise<void>

    a promise that resolves after the renderers have been updated

Row

  • Fetches rows from an associated data table (associated to the active data table) based on a set of row idxs from the parent (active) data table and the column IDs from the associated data table. See AssociatedRowsRequest.

    example

    Fetch rows from an associated data table based on the parent row idxs 0, 1 and 2, only return row data for the ID and Data column.

    try {
    const response = await publisher.fetchAssociatedRows({
    id: 'ba5567af-f353-4acb-88b2-8acafcb6851e',
    columns: ['ba5567af-f353-4acb-88b2-8acafcb6851eiID', 'ba5567af-f353-4acb-88b2-8acafcb6851esData'],
    rows: [0, 1, 2],
    });
    for (let i = 0; i < response.length; i++) {
    console.log('Parent row idx', response.idx);
    console.log('Associated rows', response.rows);
    }
    } catch (error) {
    console.log('Error fetching associated rows', error);
    }
    throws

    Error

    Parameters

    Returns Promise<{ idx: number; rows: Row[] }[]>

    promise providing the rows for the associated data table, grouped by parent row idx

  • Fetches the number of rows, filtered rows and marked rows for the active data table and, optionally, the same information for an array of expressions, for the active data table.

    example

    Fetch the row count data for the active data table.

    try {
    const response = await publisher.fetchRowCounts();
    console.log('Marked row count', response.markedRowCount);
    console.log('Filtered row count', response.rowCount);
    console.log('Before-filtering row count', response.tableRowCount);
    } catch (error) {
    console.log('Error fetching row counts', error);
    }
    example

    Fetch the row count data for a list of expressions for the active data table.

    try {
    const response = await publisher.fetchRowCounts({
    expressions: [
    { id: 'unique-expression-name-preferably-an-uid-1', expression: '[MW] <= 400' },
    { id: 'unique-expression-name-preferably-an-uid-2', expression: '[HBA] <= 5' },
    ],
    });
    console.log('Data table marked row count', response.markedRowCount);
    console.log('Data table filtered row count', response.rowCount);
    console.log('Data table before-filtering row count', response.tableRowCount);
    for (let i = 0; i < response.expressionCount.length; i++) {
    console.log('Row count data for expression', response.expressionCount[i]);
    }
    } catch (error) {
    console.log('Error fetching row counts', error);
    }
    throws

    Error

    Parameters

    • Optional request: RowCountsRequest

      optional object defining the row count request

    Returns Promise<RowCountsResponse>

    promise providing the row counts response

  • Fetches an object that contains 2 arrays that contain the row indexes for the rows that are marked and filtered for the provided visible row range or rows or array of row indexes.

    example

    Fetch the filtered and marked row indexes for the array of row idxs.

    try {
    const response = await publisher.fetchRowStates({ rows: [2, 4 ,5, 6] });
    console.log('filtered', rowStates.filtered, 'marked', rowStates.marked);
    } catch (error) {
    console.log('Error fetching row states', error);
    }
    example

    Fetch the filtered and marked row indexes for a range for rows.

    try {
    const response = await publisher.fetchRowStates({ from: 12, count: 200 });
    console.log('filtered', rowStates.filtered, 'marked', rowStates.marked);
    } catch (error) {
    console.log('Error fetching row states', error);
    }
    throws

    Error

    Parameters

    Returns Promise<RowStates>

    promise that provides an object containing the array of marked and filtered row indexes.

  • Fetches an array of rows from the active data table typically based on either a range defined by the starting view row index from and the number of rows to retrieve count or an array of table row idxs.

    example

    Fetch the first 10 rows from the active data table in view order (i.e. after sorting and filtering).

    try {
    const rows = await publisher.fetchRows({ from: 0, count: 10 });
    console.log('rows', rows);
    } catch (error) {
    console.log('Error fetching rows', error);
    }
    example

    Fetch 5 rows using table row indexes (i.e. before sorting or filtering).

    try {
    const rows = await publisher.fetchRows({ rows: [3, 45, 56, 84, 100] });
    console.log('rows', rows);
    } catch (error) {
    console.log('Error fetching rows', error);
    }
    example

    Fetch all the marked rows.

    try {
    const rows = await publisher.fetchRows({ rows: 'marked' });
    console.log('rows', rows);
    } catch (error) {
    console.log('Error fetching rows', error);
    }
    example

    Fetch the first 100 marked rows.

    try {
    const rows = await publisher.fetchRows({ rows: 'marked', limit: 100 });
    console.log('rows', rows);
    } catch (error) {
    console.log('Error fetching rows', error);
    }
    throws

    Error

    Parameters

    Returns Promise<Row[]>

    a promise that provides the array of row objects

  • Fetches the rows idxs that where the values in the provided array match the values in the indicated columns.

    example

    Fetch the row idxs where the values in the provided columns ('ID' and 'Data' columns) match either 1 and 'Dog' or 2 and 'Cat'

    try {
    const idxs = await publisher.fetchRows({
    columns: [
    'ba5567af-f353-4acb-88b2-8acafcb6851eiID',
    'ba5567af-f353-4acb-88b2-8acafcb6851esAnimal',
    ],
    values: [
    [1, 'Dog'],
    [2, 'Cat'],
    ],
    });
    console.log('row idxs', idxs);
    } catch (error) {
    console.log('Error fetching rows by values', error);
    }
    throws

    Error

    Parameters

    Returns Promise<number[]>

    array of row indexes that match the provided query

  • setActiveRow(request: { row: null | number }): Promise<void>
  • setActiveRow(request: { row: null | number }): Promise<void>
  • Sets the active row in the Spotfire Analyst. This does nothing in Spotfire WebPlayer as active rows are not supported in the WebPlayer.

    example

    Make the row with idx = 2 the active row.

    try {
    await publisher.setActiveRow({ row: 2 });
    } catch (error) {
    console.log('Error setting the active row', error);
    }
    throws

    Error

    category

    Row

    Parameters

    • request: { row: null | number }

      an object containing the row idx for the data table row to make 'active' or null if there should be no active row.

      • row: null | number

        the row idx or null

    Returns Promise<void>

    promise that resolves after the active row has been set

  • Sets the active row in the Spotfire Analyst. This does nothing in Spotfire WebPlayer as active rows are not supported in the WebPlayer.

    example

    Make the row with idx = 2 the active row.

    try {
    await publisher.setActiveRow({ row: 2 });
    } catch (error) {
    console.log('Error setting the active row', error);
    }
    throws

    Error

    category

    Row

    Parameters

    • request: { row: null | number }

      an object containing the row idx for the data table row to make 'active' or null if there should be no active row.

      • row: null | number

        the row idx or null

    Returns Promise<void>

    promise that resolves after the active row has been set

Spotfire UI

  • fetchShowTitle(): Promise<{ visible: boolean }>
  • Returns true if the current visual is displaying the title bar.

    example

    Find out with the current visual is displaying the title bar.

    try {
    const titleBarVisible = await publisher.fetchShowTitle();
    console.log('Is title bar visible', titleBarVisible);
    } catch (error) {
    console.log('Error fetching title bar visibility', error);
    }
    throws

    Error

    Returns Promise<{ visible: boolean }>

    promise that resolves to indicate whether the current visual is displaying the title bar

  • Returns the version of Spotfire.

    example

    Get the Spotfire version information.

    try {
    const version = await publisher.fetchSpotfireVersion();
    console.log('Version information', version);
    } catch (error) {
    console.log('Error fetching version information', error);
    }
    throws

    Error

    Returns Promise<SpotfireVersion>

    promise that resolves to provide Spotfire version info.

  • fetchTitle(): Promise<{ title: string }>
  • Returns the title of the current visual.

    example

    Get the title of the current visual.

    try {
    const response = await publisher.fetchTitle();
    console.log('Title', response.title);
    } catch (error) {
    console.log('Error fetching title', error);
    }
    throws

    Error

    Returns Promise<{ title: string }>

    promise that resolves to give the title of the visual

  • Fetches a list of the visuals either for the current page, the page referenced by the provided ID or all the visuals in the document.

    example

    Get all the visuals in the document.

    try {
    const response = await publisher.fetchVisuals();
    console.log('visuals', response.visuals);
    } catch (error) {
    console.log('Error fetching visuals', error);
    }
    example

    Get the visuals for the current ('active') page.

    try {
    const response = await publisher.fetchVisuals({ id: 'active' });
    console.log('visuals', response.visuals);
    } catch (error) {
    console.log('Error fetching visuals', error);
    }
    throws

    Error

    Parameters

    Returns Promise<{ visuals: Visual[] }>

    object containing the list of visuals

  • Maximize or minimize a visual on the current page.

    example

    Maximize the visual with the title 'Visual To Maximize'.

    try {
    const response = await publisher.maximizeVisual({ title: 'Visual To Maximize', maximize: true });
    console.log('response', response);
    } catch (error) {
    console.log('Error maximizing visual', error);
    }
    example

    Maximize the current visual.

    try {
    const response = await publisher.maximizeVisual({ maximize: true });
    console.log('response', response);
    } catch (error) {
    console.log('Error maximizing visual', error);
    }
    throws

    Error

    Parameters

    Returns Promise<MaximizeVisualResponse>

    promise that resolves after the visual has been maximized/minimized

  • Sends a message to the Spotfire notifcations panel.

    example

    Display a warning message in the Spotfire notification panel.

    try {
    await publisher.notify({
    level: 'warn',
    title: 'Something is not right',
    summary: 'Not sure what',
    })
    } catch (error) {
    console.log('Error notifying', error);
    }
    throws

    Error

    Parameters

    Returns Promise<void>

    promise that resolves after the notification has been issued

  • openDataTablePropertyDialog(): Promise<void>
  • Opens the Spotfire Analyst data tables property dialog. This does not work in WebPlayer.

    example

    Open the data table property.

    try {
    const response = await publisher.openDataTablePropertyDialog();
    } catch (error) {
    console.log('Error opening data table property dialog', error);
    }
    throws

    Error

    Returns Promise<void>

    a promise that resolves after the property dialog is open

  • openExpressionEditor(request: { expression: string; tableId?: string; whereClause: boolean }): Promise<{ expression: string }>
  • Opens the Spotfire Analyst expression editor. This does not work in WebPlayer.

    example

    Open the expression editor with an initial expression.

    try {
    const response = await publisher.openExpressionEditor({
    whereClause: false,
    expression: '[HBA] < 5',
    });
    } catch (error) {
    console.log('Error opening expression editor', error);
    }
    throws

    Error

    Parameters

    • request: { expression: string; tableId?: string; whereClause: boolean }

      object containing data to configure the expression editor

      • expression: string
      • Optional tableId?: string
      • whereClause: boolean

    Returns Promise<{ expression: string }>

    a promise that resolves after the expression editor has been closed providing the expression the user entered.

  • Opens the native file dialog in Spotfire Analyst. This does not work in WebPlayer.

    example

    Open the file dialog in a mode that let the user choose a folder.

    try {
    const response = await publisher.openFileDialog({ mode: 'folder' });
    } catch (error) {
    console.log('Error opening file dialog', error);
    }
    throws

    Error

    Parameters

    Returns Promise<FileDialogResponse>

    a promise that resolves once the user has selected files/directory

  • openInBrowser(url: string): Promise<void>
  • Opens the provided URL in a new browser window using the system default browser.

    example

    Opens the URL in a browser.

    try {
    await publisher.openInBrowser('http://somegreatwebsite.com')
    } catch (error) {
    console.log('Error opening link in browser', error);
    }
    throws

    Error

    Parameters

    • url: string

      the URL to open in a browser

    Returns Promise<void>

    promise that resolves after the browser has opened

  • setActiveVisual(request?: { visualId?: string }): Promise<void>
  • Sets the visual with the provided ID as the active visual. If visualId (or request) is not defined, the visual from which the request was made will become the active visual.

    throws

    Error

    Parameters

    • Optional request: { visualId?: string }

      the request containing the visual ID

      • Optional visualId?: string

    Returns Promise<void>

    promise that resolves after setting the active visual

  • setShowTitle(request: { visible: boolean }): Promise<void>
  • Sets whether the title bar for the current visual is displayed.

    throws

    Error

    Parameters

    • request: { visible: boolean }

      object containing a boolean for whether the visual should be displayed

      • visible: boolean

    Returns Promise<void>

    promise that resolves after setting the title bar visibility

  • setTitle(request: { title: string }): Promise<void>
  • Sets the title for the current visual.

    throws

    Error

    Parameters

    • request: { title: string }

      object containing the title for the visual

      • title: string

    Returns Promise<void>

    promise that resolves after setting the title

Tag column

  • Adds a new tag column to the active data table.

    example

    Add a new tag column to the active data table named 'My new tag column' with the initial tags 'Dog', 'Cat' and 'Fish',

    try {
    const request = {
    name: 'My new tag column',
    values: ['Dog', 'Cat', 'Fish'],
    };
    const response = await publisher.addTagColumn(request);
    console.log('New tag column details', response);
    } catch (error) {
    console.log('Error adding tag column', error);
    }
    throws

    Error

    Parameters

    • request: AddTagColumnRequest

      object defining the name of the tag column and the allowable values for the tag column

    Returns Promise<AddTagColumnResponse>

    promise that resolves after adding the tag column

  • Replaces possible values for tag column.

    example

    Replace the tag values with 'Dog', 'Cat', 'Fish' and 'Badger',

    try {
    const request = {
    id: 'ba5567af-f353-4acb-88b2-8acafcb6851esTagAnimal',
    values: ['Dog', 'Cat', 'Fish', 'Badger'],
    };
    await publisher.setTagColumnValues(request);
    } catch (error) {
    console.log('Error updating tag values', error);
    }
    throws

    Error

    Parameters

    Returns Promise<void>

    promise that resolves after replacing tag values is complete

  • Sets the provided tag on the rows with the provided idxs, or marked rows, for the provided tag column.

    example

    Set the tag 'Fish' on the marked rows.

    try {
    const request = {
    id: 'ba5567af-f353-4acb-88b2-8acafcb6851esTagAnimal',
    rows: 'marked',
    tag: 'Fish',
    };
    await publisher.tagRows(request);
    } catch (error) {
    console.log('Error setting tag on rows', error);
    }
    exmaple

    Set the tag 'Dog' on the rows with the provided idxs.

    try {
    const request = {
    id: 'ba5567af-f353-4acb-88b2-8acafcb6851esTagAnimal',
    rows: [0, 12, 14],
    tag: 'Dog',
    };
    await publisher.tagRows(request);
    } catch (error) {
    console.log('Error setting tag on rows', error);
    }
    throws

    Error

    Parameters

    Returns Promise<void>

    promise that resolves once tags have been applied to the rows

Util

  • createHtmlImageElement(imageData: CellImageData): HTMLImageElement
  • Returns an HTMLImageElement give the provided image data.

    Parameters

    Returns HTMLImageElement

    the HTMLImageElement

  • Creates image data URI given the provided image data.

    Parameters

    Returns string

    the HTMLImageElement

  • getVersion(): string
  • Returns string

    the version of publisher.

  • isAuthorMode(): boolean
  • Returns boolean

    true if Spotfire is in author mode i.e. 'Editing' instead of 'Viewing'.

  • isStaticMode(): boolean
  • Returns boolean

    true if we are in static mode (i.e. print) environment, false if not.

  • Test to see if the column is a tag column. This looks for the tags property on the provided column.

    Parameters

    Returns column is TagDataTableColumn

    true if the provided column is a TagDataTableColumn

  • isWebPlayer(): boolean
  • Returns boolean

    true if we are in WebPlayer environment, false if thick client.

  • Convert the provided DataType to the corresponding SpotfireDataType.

    Parameters

    Returns SpotfireDataType

    the SpotfireDataType

  • whenReady(request?: { unrestrictedFrameCommunication?: boolean }): Promise<{ authorMode: boolean; staticMode: boolean; webPlayer: boolean }>
  • The whenReady method that should (nearly) always be the first method that any application using Publisher should call. Once that has executed successfully all other methods defined in the Publisher API should be safe to call. Think of this as the Publisher equivalent of window.onload.

    example

    Use the whenReady method to make sure that all other Publisher methods are safe to call.

    <!DOCTYPE html>
    <html lang="en">

    <head>
    <meta charset="UTF-8">
    <script src='./publisher.min.js'></script>
    <title>Hello World</title>
    </head>
    <body>
    <script>
    publisher.whenReady()
    .then((e) => {
    console.log('Publisher is ready to use', e);
    return publisher.fetchActiveConfiguration();
    })
    .then((activeConfiguration) => {
    console.log('Active configuration', activeConfiguration);
    })
    .catch ((error) => {
    console.error(error);
    });
    </script>
    </body>
    </html>

    Parameters

    • Optional request: { unrestrictedFrameCommunication?: boolean }

      parameters to pass to whenReady

      • Optional unrestrictedFrameCommunication?: boolean

        whether the application should allow 'undrestricted' frame commmunication. This only makes a difference if clients are not able to control the names of iframes in publisher apps.

    Returns Promise<{ authorMode: boolean; staticMode: boolean; webPlayer: boolean }>

    a promise that once resolved provides information about the Spotfire UI i.e. authorMode, whether Spotfire is in 'Editing' or 'Viewing' mode; webPlayer, whether the app is being used in the WebPlayer rather than Analyst; and staticMode, whether this publisher instance has been loaded in the print environment.

Value group

  • Fetches the set of rows indexes that define a distinct set of values for the provided value group as well as the number of rows that contain each unique value.

    remarks

    This assumes that a column has been set for the desired value group, see setValueGroupColumn.

    example

    Fetch the unique rows idxs for 'valueGroup2', then fetch the first 10 rows.

    try {
    const response = await publisher.fetchUniqueValueGroupRows({ valueGroup: 'valueGroup2' });
    const idxs = response.data.map((obj) => obj.idx);
    console.log(idxs);
    const rows = await publisher.fetchRows({ rows: idxs.slice(0, 10) });
    console.log(rows);
    } catch (error) {
    console.log('Error fetching first 10 rows from valueGroup2', error);
    }
    throws

    Error

    Parameters

    Returns Promise<UniqueValueGroupRows>

    promise that provides an object containing the array of row indexes (where each is the first instance of a unique value in the value group) and the number of rows that contain each value.

  • Fetches the row indexes for the value groups and the row indexes for the intersection of the value groups. The value group grid is computed greedily by ordering the value groups so that there is maximal intersection of groupings from valueGroup1 and valueGroup2 at cell 0,0 (the top left corner of a matrix).

    example

    Fetch the value group grid for the first 10 uknique values from value group 1 and 2.

    try {
    const params = {
    valueGroup1: { from: 0, count: 10 },
    valueGroup2: { from: 0, count: 10 },
    };
    const response = await publisher.fetchValueGroupGrid(params);
    console.log(response.valueGroup1Idx);
    console.log(response.valueGroup2Idx);
    console.log(response.grid);
    } catch (error) {
    console.log('Error fetching value group grid', error);
    }
    throws

    Error

    Parameters

    Returns Promise<ValueGroupGrid>

    promise that provides an object containing the results of the value group intersection

  • Controls the marking of rows assigned to a value group. Value groups represent groups of duplicate row values in columns. If any row of a set of duplicate row values is marked, this will mark all rows that have the duplicate value in the value group column e.g.

    example

    Mark all the rows that contain identical values defined by 'valueGroup1' for row 0.

    try {
    publisher.markValueGroupRows({ valueGroup: 'valueGroup1', rows: [0], ctrl: false, shift: false });
    } catch (error) {
    console.log('Error marking value group rows', error);
    }
    throws

    Error

    Parameters

    Returns Promise<void>

    promise that resolves after the value group rows have been marked

  • Assigns the column to be used for computing a value group. Once a column is assigned to a column it is possible to get a list of row idxs, where each of them represents the first instance of a unique value from the assigned column.

    example

    Assign the column with id = 'ba5567af-f353-4acb-88b2-8acafcb6851eiCode' to 'valueGroup2'.

    try {
    await publisher.setValueGroupColumn({
    valueGroup: 'valueGroup2',
    id: 'ba5567af-f353-4acb-88b2-8acafcb6851eiCode',
    });
    } catch (error) {
    console.log('Error assigned value group column', error);
    }
    throws

    Error

    Parameters

    Returns Promise<void>

    promise that resolves after setting the value group column

Generated using TypeDoc