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

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 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
  • 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
  • updateBindings(bindings: Record<string, unknown>): void
  • Add one or more bindings to the existing ones. In case of conflicts, override the existing ones.

    For more information about each, see https://hub.graphistry.com/docs/api/2/rest/upload/

    Parameters

    • bindings: Record<string, unknown>

      JSON dictionary of bindings to be added to the existing ones

    Returns void

  • 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

    Returns Promise<Dataset>

    Promise that resolves when the dataset is uploaded

  • createDataset(client: Client, bindings: Record<string, unknown>): Promise<string>
  • Parameters

    • client: Client
    • bindings: Record<string, unknown>

    Returns Promise<string>

  • fillMetadata(data: any): void

Properties

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

Constructors

Accessors

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