Options
All
  • Public
  • Public/Protected
  • All
Menu

Datasets are how to combine files into a single visualizable graph. Powerfully, you can also specify visualization settings and data-driven visual encodings as part of your dataset's bindings.

For the many options, see the JSON documentation.




example

Create a dataset from edges and upload using async/await

import { Dataset } from '@graphistry/node-api';
const dataset = new Dataset(
{
node_encodings: { bindings: { } },
edge_encodings: { bindings: { source: 's', destination: 'd' } },
metadata: {},
name: 'testdata',
},
edgesFile
);
await dataset.upload(client);
console.log(`Dataset ${dataset.datasetID} uploaded to ${dataset.datasetURL}`);

example

Create a dataset from nodes + edges and upload using promises

import { Dataset } from '@graphistry/node-api';
const dataset = new Dataset(
{
node_encodings: { bindings: { 'node': 'n' } },
edge_encodings: { bindings: { 'source': 's', 'destination': 'd' } },
metadata: {},
name: 'testdata',
},
edgesFile,
nodesFile
);
dataset.upload(client).then(
() => console.log(`Dataset ${dataset.datasetID} uploaded to ${dataset.datasetURL}`)
).catch(err => console.error('oops', err));

example

Create a dataset using Arrow

import { tableFromArrays, tableToIPC, Table } from 'apache-arrow';
import { EdgeFile } from '@graphistry/node-api';

//columnar data is fastest; column per attribute; reuse across datasets
const edgesJSON = {'s': ['a1', 'b2'], 'd': ['b2', 'c3']};
const edgesTable: Table = tableFromArrays(edgesJSON);
const edgesUint8: Uint8Array = tableToIPC(edgesArr, 'file');
const edgesFile = new EdgeFile(edgesUint8, 'arrow');

example

Add files after the Dataset is instantiated but before it has been uploaded

import { Dataset } from '@graphistry/node-api';
const dataset = new Dataset(
{
node_encodings: { bindings: { 'node': 'n' } },
edge_encodings: { bindings: { 'source': 's', 'destination': 'd' } },
metadata: {},
name: 'testdata',
}
);
dataset.addFile(nodesFile);
dataset.addFile(edgesFile);
await dataset.upload(client);
console.log(`Dataset ${dataset.datasetID} uploaded to ${dataset.datasetURL}`);

example

Set privacy on uploaded dataset

import { Dataset, Privacy } from '@graphistry/node-api';
const dataset = new Dataset(
{
node_encodings: { bindings: { } },
edge_encodings: { bindings: { 'source': 's', 'destination': 'd' } },
metadata: {},
name: 'testdata',
}
);
dataset.addFile(edgesFile);
await dataset.upload(client);
await dataset.setPrivacy(client); // see additional options below

example

Set simple data-driven bindings for titles, colors, icons, and labels

import { Dataset } from '@graphistry/node-api';
const dataset = new Dataset(
{

// See also simple title, color, ... and complex color, size, icon, badge, ...
// https://hub.graphistry.com/docs/api/2/rest/upload/colors
// https://hub.graphistry.com/docs/api/2/rest/upload/complex/
node_encodings: {

bindings: {
'node': 'n', //id
'node_title': 'some_title_column' //optional
},

complex: {
default: {
pointSizeEncoding: {
graphType: 'point',
encodingType: 'size',
attribute: 'payment',
variation: 'categorical',
mapping: {
fixed: {
big: 500,
normal: 200,
tiny: 10
},
other: 100
}
}
}
}
},

// See also simple title, color, ... and complex color, size, icon, badge, ...
// https://hub.graphistry.com/docs/api/2/rest/upload/colors
// https://hub.graphistry.com/docs/api/2/rest/upload/complex/
edge_encodings: {

bindings: {
'source': 's', 'destination': 'd'
},

complex: {
default: {
edgeColorEncoding: {
graphType: 'point',
encodingType: 'color',
attribute: 'time',
variation: 'continuous',
colors: ['blue', 'yellow', 'red']
}
}
}
},

// Set brand & theme: Background, foreground, logo, page metadata
// https://hub.graphistry.com/docs/api/2/rest/upload/metadata/
metadata: {
bg: {
color: 'silver'
},
"logo": {
url: "http://a.com/logo.png",
}
},
name: 'testdata',
},

nodesFile,
edgesFile

// Visual and layout settings
// https://hub.graphistry.com/docs/api/1/rest/url/#urloptions
{
strongGravity: true,
edgeCurvature: 0.5
}

);
await dataset.upload();

Hierarchy

  • Dataset

Index

Methods

  • addFile(file: File): void
  • See examples at top of file

    Add an additional node or edge file to the existing ones.

    Parameters

    • file: File

      File object. Does not need to be uploaded yet.

    Returns void

  • getCreateDatasetResponse(): any
  • privacy(client: ClientType, mode?: Mode, modeAction?: ModeAction, invitedUsers?: string[], notify?: boolean, message?: string): Promise<Privacy>
  • See examples at top of file

    Set the privacy mode of the dataset. All but the client are optional.

    throws

    Error if the dataset has not been uploaded yet

    throws

    Error if server call fails

    Parameters

    • client: ClientType

      Client object

    • Optional mode: Mode

      Privacy mode. One of 'private', 'public', 'organization'

    • Optional modeAction: ModeAction

      Capability allowed when shared

    • Optional invitedUsers: string[]

      List of user IDs to share with

    • Optional notify: boolean

      Whether to notify users of the share

    • Optional message: string

      Message to include in the notification

    Returns Promise<Privacy>

    Promise that resolves when the privacy is set

  • updateBindings(bindings: Record<string, unknown>): void
  • upload(client: ClientType): Promise<Dataset>
  • See examples at top of file

    Upload the dataset to the Graphistry server.

    If files have not been uploaded yet, this method will upload them for you.

    Upon completion, attributes datasetID and datasetURL will be set, as well as createDatasetResponse and uploadResponse.

    Parameters

    • client: ClientType

      Client object

    Returns Promise<Dataset>

    Promise that resolves when the dataset is uploaded

Properties

bindings: Record<string, unknown>
edgeFiles: EdgeFile[]
nodeFiles: NodeFile[]
urlOpts: Record<string, unknown>
_createDatasetResponse: any
_datasetID?: any
_usedClientProtocolHostname?: any
createDataset: any
fillMetadata: any

Constructors

Accessors

  • get datasetID(): undefined | string
  • get datasetURL(): string