# Class: Graphistry

## Graphistry

This object wraps a HTML IFrame of a Graphistry Visualization in order to provide an API for interacting with the graph.

## Constructor

#### new Graphistry()

Source:
  - index.js, line 62
See:
  - https://github.com/ReactiveX/rxjs/blob/master/doc/observable.md

### Extends

- Observable

### Methods

#### (static) addColumns() → {Promise}

Add columns to the current graph visuzliation's dataset

Source:
  - index.js, line 133

##### Returns:

A promise to return the result of the callback

Type
  Promise

##### Example

    GraphistryJS(document.getElementById('viz'))
        .flatMap(function(g) {
            window.g = g;
            const columns = [
                ['edge', 'highways', [66, 101, 280], 'number'],
                ['point', 'theme parks', ['six flags', 'disney world', 'great america'], 'string']
            ];
            console.log('adding columns', columns);
            return g.addColumns.apply(g, columns);
        })
        .subscribe();

#### (static) addExclusion(expr) → {Promise}

Add an exclusion to the visualization with the given expression

##### Parameters:

Name | Type | Description
--- | --- | ---
`expr` | string | An expression using the same language as our in-tool exclusion and filter panel

Source:
  - index.js, line 625

##### Returns:

The result of the callback

Type
  Promise

##### Example

    GraphistryJS(document.getElementById('viz'))
        .flatMap(function (g) {
            window.g = g;
            console.log('Adding exclusion for "point:degree > 0"');
            return g.addExclusion('point:degree > 0');
        })
        .subscribe();

#### (static) addFilter(expr) → {Promise}

Add a filter to the visualization with the given expression

##### Parameters:

Name | Type | Description
--- | --- | ---
`expr` | string | An expression using the same language as our in-tool exclusion and filter panel

Source:
  - index.js, line 596

##### Returns:

The result of the callback

Type
  Promise

##### Example

    GraphistryJS(document.getElementById('viz'))
        .flatMap(function (g) {
            window.g = g;
            console.log('Adding filter for "point:degree > 0"');
            return g.addFilter('point:degree > 0');
        })
        .subscribe();

#### (static) autocenter(percentile, cbopt) → {Promise}

Center the view of the graph

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`percentile` | number |  | Controls sensitivity to outliers
`cb` | function | <optional> | Callback function of type callback(error, result)

Source:
  - index.js, line 500

##### Returns:

The result of the callback

Type
  Promise

##### Example

    GraphistryJS(document.getElementById('viz'))
        .flatMap(function (g) {
            window.g = g;
            console.log('centering');
            return g.autocenter(.90);
        })
        .subscribe();

#### (static) closeFilters() → {Promise}

Close the filters panel

Source:
  - index.js, line 438

##### Returns:

The result of the callback

Type
  Promise

##### Example

    GraphistryJS(document.getElementById('viz'))
        .flatMap(function (g) {
            window.g = g;
            console.log('closing filters');
            return g.closeFilters();
        })
        .subscribe();

#### (static) encodeColor(graphTypeopt, attributeopt, variationopt, colorsopt) → {Promise}

Change colors based on an attribute

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`graphType` | GraphType | <optional> | 'point' or 'edge'
`attribute` | Attribute | <optional> | name of data column, e.g., 'degree'
`variation` | Variant | <optional> | If there are more bins than colors, use 'categorical' to repeat colors and 'continuous' to interpolate
`colors` | Array | <optional> | array of color name or hex codes

Source:
  - index.js, line 171

##### Returns:

The result of the callback

Type
  Promise

##### Example

    GraphistryJS(document.getElementById('viz'))
        .flatMap(function (g) {
            window.g = g;
            return g.encodeColor('point', 'degree', 'categorical', ['black', 'white'])
        })
        .subscribe();

#### (static) encodeIcons(graphTypeopt, attributeopt) → {Promise}

Change icons based on an attribute

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`graphType` | GraphType | <optional> | 'point' or 'edge'
`attribute` | Attribute | <optional> | name of data column, e.g., 'icon'

Source:
  - index.js, line 229

##### Returns:

The result of the callback

Type
  Promise

##### Example

    GraphistryJS(document.getElementById('viz'))
        .flatMap(function (g) {
            window.g = g;
            return g.encodeIcons('point', 'icon')
        })
        .subscribe();

#### (static) encodeSize(graphTypeopt, attributeopt) → {Promise}

Change size based on an attribute

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`graphType` | GraphType | <optional> | 'point'
`attribute` | Attribute | <optional> | name of data column, e.g., 'degree'

Source:
  - index.js, line 285

##### Returns:

The result of the callback

Type
  Promise

##### Example

    GraphistryJS(document.getElementById('viz'))
        .flatMap(function (g) {
            window.g = g;
            return g.encodeSize('point', 'community_infomap')
        })
        .subscribe();

#### (static) getCurrentWorkbook(cbopt) → {Promise}

Read the workbook ID

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`cb` | function | <optional> | Callback function of type callback(error, result)

Source:
  - index.js, line 521

##### Returns:

The result of the callback

Type
  Promise

##### Example

    GraphistryJS(document.getElementById('viz'))
        .flatMap(function (g) {
            window.g = g;
            console.log('getting workbook id');
            return g.getCurrentWorkbook();
        })
        .subscribe(function (workbook) {
            alert('id: ' + workbook.id)
        });

#### (static) labelUpdates() → {Observable.<Observable.<LabelEvent>>}

Get or create an Observable stream of all label updates from the visualization.

The Observable returned by this method emits inner Observables, where each inner Observable is tied to the lifetime of the label for which it was created.

For each label rendered in the visualization, the Observable returned by this method will create and emit a new inner Observable. The inner Observable will emit events when the label changes. For example, if the user clicks on the label, or the label changes position because of a pan/zoom, the inner Observable will emit an event.

The inner Observable for a label will complete if the label is removed from the screen.

Source:
  - index.js, line 725

##### Returns:

An Observable of inner Observables, where each inner Observable represents the lifetime of a label in the visualization.

Type
  Observable.<Observable.<LabelEvent>>

#### (static) resetColor(graphTypeopt) → {Promise}

Reset color to value at page load

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`graphType` | GraphType | <optional> | 'point' or 'edge'

Source:
  - index.js, line 200

##### Returns:

The result of the callback

Type
  Promise

##### Example

    GraphistryJS(document.getElementById('viz'))
        .flatMap(function (g) {
            window.g = g;
            return g.encodeColor('point', 'degree', 'categorical', ['black', 'white'])
            return g.resetColor('point')
        })
        .subscribe();

#### (static) resetIcons(graphTypeopt) → {Promise}

Reset icons to value at page load

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`graphType` | GraphType | <optional> | 'point' or 'edge'

Source:
  - index.js, line 256

##### Returns:

The result of the callback

Type
  Promise

##### Example

    GraphistryJS(document.getElementById('viz'))
        .flatMap(function (g) {
            window.g = g;
            return g.encodeIcons('point', 'icon')
            return g.resetIcons('point')
        })
        .subscribe();

#### (static) resetSize(graphTypeopt) → {Promise}

Reset size to value at page load

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`graphType` | GraphType | <optional> | 'point'

Source:
  - index.js, line 312

##### Returns:

The result of the callback

Type
  Promise

##### Example

    GraphistryJS(document.getElementById('viz'))
        .flatMap(function (g) {
            window.g = g;
            return g.encodeSize('point', 'community_infomap')
            return g.resetSize('point')
        })
        .subscribe();

#### (static) saveWorkbook() → {Promise}

Save the current workbook. A saved workbook will persist the analytics state of the visualization, including active filters and exclusions

Source:
  - index.js, line 550

##### Returns:

The result of the callback

Type
  Promise

##### Example

    GraphistryJS(document.getElementById('viz'))
        .flatMap(function (g) {
            window.g = g;
            return g.saveWorkbook();
        })
        .subscribe();

#### (static) subscribeLabels(subscriptions) → {Subscription}

Subscribe to label change and exit events

##### Parameters:

Name | Type | Description
--- | --- | ---
`subscriptions` | subscriptions | A list of subscriptions that will subscribe to any label updates

Source:
  - index.js, line 823

##### Returns:

The result of the callback

Type
  Subscription

#### (static) tickClustering(ticks) → {Promise}

Run a number of steps of Graphistry's clustering algorithm

##### Parameters:

Name | Type | Description
--- | --- | ---
`ticks` | number | The number of ticks to run

Source:
  - index.js, line 463

##### Returns:

The result of the callback

Type
  Promise

##### Example

    GraphistryJS(document.getElementById('viz'))
        .flatMap(function (g) {
            window.g = g;
            console.log('starting to cluster');
            return g.tickClustering();
        })
        .subscribe();

#### (static) toggleHistograms(turnOnopt) → {Promise}

Toggle histogram panel

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`turnOn` | boolean | <optional> | Whether to make panel visible

Source:
  - index.js, line 405

##### Returns:

The result of the callback

Type
  Promise

##### Example

    GraphistryJS(document.getElementById('viz'))
        .flatMap(function (g) {
            window.g = g;
            console.log('opening histogram panel');
            return g.toggleHistograms(true);
        })
        .subscribe();

#### (static) toggleInspector(turnOnopt) → {Promise}

Toggle inspector panel

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`turnOn` | boolean | <optional> | Whether to make panel visible

Source:
  - index.js, line 372

##### Returns:

The result of the callback

Type
  Promise

##### Example

    GraphistryJS(document.getElementById('viz'))
        .flatMap(function (g) {
            window.g = g;
            console.log('opening inspector panel');
            return g.toggleInspector(true);
        })
        .subscribe();

#### (static) toggleLeftPanel(panelopt, turnOnopt) → {Promise}

Toggle a leftside panel

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`panel` | string | <optional> | Name of panel: filters, exclusions, scene, labels, layout
`turnOn` | boolean | <optional> | Whether to make panel visible, or turn all off

Source:
  - index.js, line 338

##### Returns:

The result of the callback

Type
  Promise

##### Example

    GraphistryJS(document.getElementById('viz'))
        .flatMap(function (g) {
            window.g = g;
            console.log('opening filters');
            return g.toggleLeftPanel('filters', true);
        })
        .subscribe();

#### (static) toogleToolbar(show) → {Promise}

Hide or Show Toolbar UI

##### Parameters:

Name | Type | Description
--- | --- | ---
`show` | boolean | Set to true to show toolbar, and false to hide toolbar.

Source:
  - index.js, line 577

##### Returns:

The result of the callback

Type
  Promise

##### Example

    <button onclick="window.graphistry.toggleToolbar(false)">Hide toolbar</button>
    <button onclick="window.graphistry.toggleToolbar(true)">Show toolbar</button>

#### (static) updateSetting(name, val) → {Promise}

Modify a settings value in the visualization Key settings: showArrows, pruneOrphans, edgeOpacity, edgeSize, pointOpacity, pointSize, labelOpacity, labelEnabled, labelPOI, labelHighlightEnabled, zoom

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | string | the name of the setting to change
`val` | string | the value to set the setting to.

Source:
  - index.js, line 654

##### Returns:

The result of the callback

Type
  Promise

#### (static) updateZoom(level, val) → {Promise}

Update the camera zoom level

##### Parameters:

Name | Type | Description
--- | --- | ---
`level` | string | Controls how far to zoom in or out.
`val` | string | the value to set the setting to.

Source:
  - index.js, line 710

##### Returns:

The result of the callback

Type
  Promise

#### subscribe(nextnullable, errornullable, completednullable) → {Subscription}

The subscribe method triggers the execution of the Observable, causing the values within to be pushed to a callback. An Observable is like a pipe of water that is closed. When subscribe is called, we open the valve and the values within are pushed at us. These values can be received using either callbacks or an Observer object.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`next` | Observable~nextCallback | <nullable> | a callback that accepts the next value in the stream of values
`error` | Observable~errorCallback | <nullable> | a callback that accepts an error that occurred while evaluating the operation underlying the Observable stream
`completed` | Observable~completeCallback | <nullable> | a callback that is invoked when the Observable stream has ended, and the Observable~nextCallback will not receive any more values

Inherited From:
  - Observable#subscribe
Source:
  - index.js, line 1036

##### Returns:

Type
  Subscription

#### (inner) lift(operator) → {Observable}

Creates a new Observable with this as the source, and the passed operator as the new Observable's operator.

##### Parameters:

Name | Type | Description
--- | --- | ---
`operator` | Operator | the operator defining the operation to take on the observable

Source:
  - index.js, line 93

##### Returns:

a new observable with the operator applied

Type
  Observable