# 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 122

### Extends

- Observable

### Methods

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

Add columns to the current graph visuzliation's dataset

Source:
  - index.js, line 170

##### 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 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 661

##### Returns:

The result of the callback

Type
  Promise

##### Example

    graphistry.addExclusion('degree > 0');

#### (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 638

##### Returns:

The result of the callback

Type
  Promise

##### Example

    graphistry.addFilter('degree > 0');

#### (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 545

##### 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 483

##### 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 216

##### 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 274

##### 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 330

##### 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}

Center the view of the graph

##### Parameters:

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

Source:
  - index.js, line 566

##### Returns:

The result of the callback

Type
  Promise

##### Example

    GraphistryJS(document.getElementById('viz'))
        .flatMap(function (g) {
            window.g = g;
            return g.getCurrentWorkbook(function (err, obj){ alert('id: ' + obj.id); });
        })
        .subscribe();

#### (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 245

##### 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 301

##### 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 357

##### 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 592

##### 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) → {Promise}

Subscribe to label events

##### Parameters:

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

Source:
  - index.js, line 754

##### Returns:

The result of the callback

Type
  Promise

#### (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 508

##### 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 450

##### 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 417

##### 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 383

##### 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 619

##### 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}

Add an to the visualization with the given expression Key settings: showArrows, pruneOrphans, edgeOpacity, edgeSize, pointOpacity, pointSize, labelOpacity, labelEnabled, labelPOI, 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 684

##### Returns:

The result of the callback

Type
  Promise

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

Add an to the visualization with the given expression

##### 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 739

##### Returns:

The result of the callback

Type
  Promise

#### (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 152

##### Returns:

a new observable with the operator applied

Type
  Observable