Options
All
  • Public
  • Public/Protected
  • All
Menu

@kineviz/graphxr-api

Index

Enumerations

Classes

Interfaces

Type Aliases

Variables API

Variables Other

Functions Algorithm

Functions Camera

Functions Category

Functions Centrality

Functions Community Detection

Functions Edge

Functions Events

Functions Filter

Functions Graph

Functions Grove

Functions Layout

Functions Legend

Functions Neo4j

Functions Node

Functions Other

Functions Path Finding

Functions Project Settings

Functions Properties

Functions Render

Functions Runtime

Functions Sort

Functions Style

Functions Transform

Functions Utility

Functions window

Type Aliases

AggregateOptions: { aggregateAlong: RelationshipId; aggregateTo: CategoryId | NodeFilter | NodeId[] | ApiNode[]; getPropertyFrom: "edge" | "node" } & AggregateProperty & NodeFilterOptions
Betweenness: number
BetweennessResult: MapPolyfill<NodeId, Betweenness>
CategoryId: Brand<string, "CategoryId">
Closeness: number
ClosenessResult: MapPolyfill<NodeId, Closeness>
Color: THREE.Color
ConnectedComponent: NodeId[]
ConnectedComponentResult: MapPolyfill<NodeId, number>
Dimension: keyof Pick<Position, "x" | "y" | "z">
DistributionOptions: NodeFilterOptions & { bin?: PropertyKey; binType?: "number" | "date" | "categorical"; dimension: Dimension; spread?: number }
EdgeFilter: Filter<ApiEdge>
EdgeId: Brand<string, "EdgeId">
EdgeStyle: keyof EdgeStyles
EdgeStyleValue: EdgeStyles[EdgeStyle]
EdgeStyles: { alpha: number; color: Color; highlight: boolean; selected: boolean; twinkled: boolean; visible: boolean; width: number }

Type declaration

  • alpha: number
  • color: Color
  • highlight: boolean
  • selected: boolean
  • twinkled: boolean
  • visible: boolean
  • width: number
Filter<T>: ((obj: T) => boolean)

Type Parameters

  • T

Type declaration

    • (obj: T): boolean
    • Parameters

      • obj: T

      Returns boolean

GetApiOptions: { graphXrVersion?: string; runtime?: Runtime }

Type declaration

  • Optional graphXrVersion?: string
  • Optional runtime?: Runtime
GraphxrEvent: "change" | "select" | "nearby" | "load"
GraphxrEventCallback: ((event: GraphxrEvent, data?: unknown) => void) & { previousState?: GraphxrReduxState }
GraphxrEventCallbackId: Brand<string, "ApiEventCallbackId">
InterpolatePositionFunction: ((t: number, initial: Position, final: Position) => Position)

Type declaration

LayoutFunction: ((view: LayoutGraph) => LayoutResult)

Type declaration

LayoutNodesFunction: ((context: LayoutContext) => LayoutResult)

Type declaration

LegacyEdge: EdgeStyles & { _neo4jID?: string; id: EdgeId; name: RelationshipId; properties: Properties; sourceId: NodeId; targetId: NodeId; uid: string }
LegacyNode: NodeStyles & { category: CategoryId; collection?: LegacyNodeCollection; connectedEdge: EdgeId[]; data: { detail: { data: Properties; type: CategoryId } }; id: NodeId; neighbor: NodeId[]; properties: Properties }
LouvainResult: MapPolyfill<NodeId, number>
MapFormula: ((value: PropertyValue, properties: Properties) => PropertyValue)

Type declaration

MergeRelationshipsData: { edge: Properties; source: Properties; target: Properties }

Type declaration

Neo4jGraphData: { nodes: Neo4jNode[]; relationships: Neo4jEdge[] }

Type declaration

Neo4jId: number
Neo4jQuery: Brand<string, "Neo4jQuery">
Neo4jQueryFunction: (() => Neo4jQuery)

Type declaration

Neo4jTableData: (string | number | null)[][]
NodeFilter: Filter<ApiNode>
NodeId: Brand<string, "NodeId">
NodeIdToPosition: SafeMap<NodeId, Position>
NodeIdToPositionEntry: [NodeId, Position]
NodeStyle: keyof NodeStyles
NodeStyleValue: NodeStyles[NodeStyle]
NodeStyles: { alpha: number; color: Color; highlight: boolean; icon: number; pinned: boolean; position: Position; selected: boolean; size: number; twinkled: boolean; visible: boolean }

Type declaration

  • alpha: number
  • color: Color
  • highlight: boolean
  • icon: number
  • pinned: boolean
  • position: Position
  • selected: boolean
  • size: number
  • twinkled: boolean
  • visible: boolean
ObjectType: {}

Type declaration

  • [key: string]: boolean | string | number | null | undefined
ObservableLayoutGraph: Iterator<LayoutGraph> & LayoutGraph
ObserveCallback: (() => void)

Type declaration

    • (): void
    • Returns void

PageRank: number
PageRankResult: SafeMap<NodeId, PageRank>
Path: Parent[]
Position: THREE.Vector3
Properties: Record<PropertyKey, PropertyValue>
PropertyKey: Brand<string, "PropertyKey">
PropertyValue: any
RelationshipId: Brand<string, "RelationshipId">
SerializedEdgeStyles: Partial<Omit<EdgeStyles, "color"> & { color: number }>
SerializedNodeStyles: Partial<Omit<NodeStyles, "color"> & { color: number }>
Sort<T>: ((left: T, right: T) => number)

Type Parameters

  • T

Type declaration

    • (left: T, right: T): number
    • Parameters

      • left: T
      • right: T

      Returns number

API Variables

Api: { DIMENSIONS: Record<"x" | "y" | "z", "x" | "y" | "z">; ExpandNodesEdgeDirection: typeof ExpandNodesEdgeDirection; ExpandNodesStatusCode: typeof ExpandNodesStatusCode; _minimumGraphxrVersion: string; _version: string; aggregate: ((options: AggregateOptions) => TransformFunction); aggregateFormula: { average: ((values: any[]) => number); concatenate: ((values: any[]) => null | string); count: ((values: any[]) => number); max: ((values: any[]) => number); min: ((values: any[]) => number); range: ((values: any[]) => string); sum: ((values: any[]) => number); takeFirst: ((values: any[]) => any) }; alignBy: ((options: AlignByOptions) => LayoutFunction); applyLayout: ((view: LayoutGraph, computeLayout: LayoutFunction, tweenOverrides?: Partial<TweenLayoutOptions>) => Promise<NodeIdToPosition>); areGraphSnapshotsEqual: ((left: GraphSnapshot, right: GraphSnapshot, options: Partial<AreGraphSnapshotsEqualOptions>) => boolean); betweenness: ((graph: LayoutGraph) => BetweennessResult); circle: ((options?: NodeFilterOptions) => LayoutFunction); closeness: ((graph: LayoutGraph) => ClosenessResult); collectNodes: ((options?: CollectNodesOptions) => TransformFunction); colorNodesByProperty: ((options: ColorNodesByPropertyOptions) => void); comparePropertyValues: ((left: any, right: any, ascending?: boolean) => number); connectedComponent: ((graph: LayoutGraph) => ConnectedComponentResult); convertToScreenCoordinates: ((position: Vector3) => Position); createNodes: ((options: CreateNodesOptions) => TransformFunction); cube: ((options?: NodeFilterOptions) => LayoutFunction); dijkstra: ((graph: LayoutGraph, options: DijkstraOptions) => Path[]); dispatchGraphDataUpdate: (() => void); distributionBy: ((options: DistributionOptions) => LayoutFunction); edgesByRelationship: ((relationship: RelationshipId) => EdgeFilter); ego: ((options: EgoOptions) => LayoutFunction); expandNodes: (() => Promise<ExpandNodesStatusCode>); explodeCollections: ((options?: ExplodeCollectionsOptions) => TransformFunction); extract: ((options: ExtractOptions) => TransformFunction); flyToCenter: ((view?: LayoutGraph, nodeIds?: NodeId[], offset?: number, options?: TweenPositionOptions) => Promise<Position>); flyToPosition: ((position: Vector3, offset?: number, options?: TweenPositionOptions) => Promise<Position>); getCategoryColor: ((categoryId: CategoryId) => Color); getCategoryConfig: ((category: CategoryId) => CategoryConfig); getGraphView: (() => void); getLayoutGraph: (() => LegacyLayoutGraph); getObservableLayoutGraph: ((options?: ObservableLayoutGraphOptions) => ObservableLayoutGraph); getRuntime: (() => Runtime); getScene: (() => THREE.Group); grid: ((options?: NodeFilterOptions) => LayoutFunction); layout: ((computeLayout: LayoutNodesFunction, options?: NodeFilterOptions) => LayoutFunction); line: ((options?: NodeFilterOptions) => LayoutFunction); link: ((options: LinkOptions) => TransformFunction); louvain: ((graph: LayoutGraph) => LouvainResult); makeCollectionNode: ((category: CategoryId, __namedParameters: NodeCollection) => ApiNode); makeColor: ((hexOrR: number, g?: number, b?: number) => Color); makeEdge: ((__namedParameters: Partial<ApiEdge>) => ApiEdge); makeGraph: (() => LayoutGraph); makeNode: ((__namedParameters?: Partial<ApiNode>) => ApiNode); makeNodeId: (() => NodeId); makePosition: ((__namedParameters: Partial<Vector3>) => Position); makeRandomPosition: (() => Position); map: ((options: MapOptions) => TransformFunction); mapFormula: { toDate: ((value: any) => string); toNumber: ((value: any) => number); toString: ((value: any) => string); toWeek: ((value: any) => string) }; merge: ((options: MergeOptions) => TransformFunction); mergeNodes: ((options: MergeNodesOptions) => TransformFunction); mergeRelationships: ((options: MergeRelationshipsOptions) => TransformFunction); neo4j: ((query: Neo4jQuery, options?: Neo4jOptions) => void); nodesByCategory: ((category: CategoryId) => NodeFilter); observe: (<T>(event: GraphxrEvent, compute: ObserveCallback) => Iterator<T>); on: ((event: GraphxrEvent, callback: GraphxrEventCallback, callbackId?: GraphxrEventCallbackId) => GraphxrEventCallbackId); onChange: (<T>(cb: ObserveCallback) => Iterator<T, any, undefined>); pageRank: ((graph: LayoutGraph, options?: PageRankOptions) => PageRankResult); parametric: ((options: ParametricOptions) => LayoutFunction); random: ((options?: NodeFilterOptions) => LayoutFunction); rotate: ((options: RotateOptions) => LayoutFunction); scale: ((options?: ScaleOptions) => LayoutFunction); setAutoShowImage: ((value: boolean) => boolean); setCameraOptions: ((options: CameraOptions) => void); setCameraRotating: ((rotating: boolean) => void); setCategoryCaptionProperties: ((__namedParameters: SetCategoryCaptionPropertiesOptions) => Promise<unknown>); setCategorySizeProperty: ((__namedParameters: SetCategorySizePropertyOptions) => Promise<unknown>); setEdgeScale: ((value: number) => number); setFullscreen: ((value: boolean) => boolean); setParametricAxesOptions: ((options: Partial<AxesOptions>) => void); setRuntime: ((value: Runtime) => void); shift: ((options: ShiftOptions) => LayoutFunction); shortcut: ((options: ShortcutOptions) => TransformFunction); sleep: ((ms: number) => Promise<number>); sortByProperty: ((__namedParameters: SortByPropertyOptions) => Sort<ApiNode>); spiral: ((options?: NodeFilterOptions) => LayoutFunction); stronglyConnectedComponent: ((graph: LayoutGraph) => ConnectedComponentResult); traceNeighbors: ((view: LayoutGraph, rootId: NodeId, options?: TraceNeighborsOptions) => MapPolyfill<NodeId, boolean>); triggerForceLayout: (() => void); uncollectNodes: ((options?: UncollectNodesOptions) => TransformFunction) } = ...

Perform a runtime check of the minimum required GraphXR and API version. If minimum requirements are met, return the API. Otherwise, throw an error.

returns

a Promise that resolves to the API

since

0.0.1

Type declaration

  • DIMENSIONS: Record<"x" | "y" | "z", "x" | "y" | "z">
  • ExpandNodesEdgeDirection: typeof ExpandNodesEdgeDirection
  • ExpandNodesStatusCode: typeof ExpandNodesStatusCode
  • _minimumGraphxrVersion: string
  • _version: string
  • aggregate: ((options: AggregateOptions) => TransformFunction)
      • For each Node in the aggregateTo Category, collect the value of the targetProperty from every neighbor of that Node connected by an Edge of the aggregateAlong Relationship into an array. Then, run a mapping function formula on the array and store the resulting value in a property of the Node.

        since

        0.0.25

        example
        // For each Season Node, make a new property "episodeNumbers" which is a concatentation of all the
        // episodeNumber property values from Episodes connected to the Season along the inSeason relationship
        api.getLayoutGraph().applyTransform(api.aggregate({
        aggregateTo: 'Season',
        aggregateAlong: 'inSeason',
        getPropertyFrom: 'node',
        sourceProperty: 'episodeNumber',
        targetProperty: 'episodeNumbers',
        formula: 'concatenate'
        }))

        // For each Season Node, make a new property "maxEpisodeNumber" which is the maximum of all the
        // episodeNumber property values from inSeason edges connected to the Season.
        api.getLayoutGraph().applyTransform(api.aggregate({
        aggregateTo: 'Season',
        aggregateAlong: 'inSeason',
        getPropertyFrom: 'edge',
        sourceProperty: 'episodeNumber',
        targetProperty: 'maxEpisodeNumber',
        formula: 'max'
        }))

        // aggregateTo can be a function, a category, an array of nodes, or an array of node ids
        api.getLayoutGraph().applyTransform(api.aggregate({
        // function
        aggregateTo: node => node.category === 'Season',
        // category
        aggregateTo: 'Season',
        // array of nodes
        aggregateTo: api.getLayoutGraph().getNodes().filter(node => node.category === 'Season'),
        // array of node ids
        aggregateTo: api.getLayoutGraph().getNodes().filter(node => node.category === 'Season').map(node => node.id),
        }))

        // formula can be a function or a string
        api.getLayoutGraph().applyTransform(api.aggregate({
        // function
        formula: (values) => values.reduce((a, b) => a + b, 0),
        // string
        formula: 'sum',
        }))

        Parameters

        Returns TransformFunction

  • aggregateFormula: { average: ((values: any[]) => number); concatenate: ((values: any[]) => null | string); count: ((values: any[]) => number); max: ((values: any[]) => number); min: ((values: any[]) => number); range: ((values: any[]) => string); sum: ((values: any[]) => number); takeFirst: ((values: any[]) => any) }
    • average: ((values: any[]) => number)
        • (values: any[]): number
        • Parameters

          • values: any[]

          Returns number

    • concatenate: ((values: any[]) => null | string)
        • (values: any[]): null | string
        • Parameters

          • values: any[]

          Returns null | string

    • count: ((values: any[]) => number)
        • (values: any[]): number
        • Parameters

          • values: any[]

          Returns number

    • max: ((values: any[]) => number)
        • (values: any[]): number
        • Parameters

          • values: any[]

          Returns number

    • min: ((values: any[]) => number)
        • (values: any[]): number
        • Parameters

          • values: any[]

          Returns number

    • range: ((values: any[]) => string)
        • (values: any[]): string
        • Parameters

          • values: any[]

          Returns string

    • sum: ((values: any[]) => number)
        • (values: any[]): number
        • Parameters

          • values: any[]

          Returns number

    • takeFirst: ((values: any[]) => any)
        • (values: any[]): any
        • Parameters

          • values: any[]

          Returns any

  • alignBy: ((options: AlignByOptions) => LayoutFunction)
  • applyLayout: ((view: LayoutGraph, computeLayout: LayoutFunction, tweenOverrides?: Partial<TweenLayoutOptions>) => Promise<NodeIdToPosition>)
      • Sets the positions of Nodes. Optionally animate the position. If tween provided with the LayoutResult, use it. Override the default tweens returned by (for example) line() and circle() by providing TweenLayoutOverrides. If tween is undefined, set all the positions immediately

        since

        0.0.1

        example
        // Basic example
        GraphXR.applyLayout(GraphXR.getLayoutGraph(), GraphXR.line())

        // Layouts can be tweened, or not.
        GraphXR.applyLayout(GraphXR.getLayoutGraph(), GraphXR.circle(), {duration: 3000})
        GraphXR.applyLayout(GraphXR.getLayoutGraph(), GraphXR.cube(), {duration: 3000, interpolate: myInterpolate})

        // Define your own layout!
        GraphXR.applyLayout(
        GraphXR.getLayoutGraph(),
        {
        final: new Map(GraphXR.getNodes().map(n => [n, GraphXR.makeRandomPosition()])),
        tween: {
        duration: 3000,
        interpolate: myInterpolate,
        }
        }
        )

        // Sort and Filter can apply to the geometric layouts.
        // Also, note that you can call applyLayout on a LayoutGraph.
        GraphXR.getLayoutGraph().applyLayout(
        GraphXR.line({
        sort: 'price', // shorthand for GraphXR.sortByProperty({property: 'price', ascending: true})
        filter: GraphXR.nodesByCategory('Item'),
        })
        ))

        Parameters

        Returns Promise<NodeIdToPosition>

  • areGraphSnapshotsEqual: ((left: GraphSnapshot, right: GraphSnapshot, options: Partial<AreGraphSnapshotsEqualOptions>) => boolean)
  • betweenness: ((graph: LayoutGraph) => BetweennessResult)
      • Compute Betweenness score for each node in the graph

        since

        0.0.100

        example
        const result = api.betweenness(api.getLayoutGraph())
        view.applyTransform((graph) => {
        graph.getNodes().forEach(node => {
        node.properties.betweenness = result.get(node.id)
        })
        return graph;
        })

        Parameters

        Returns BetweennessResult

  • circle: ((options?: NodeFilterOptions) => LayoutFunction)
  • closeness: ((graph: LayoutGraph) => ClosenessResult)
      • Compute Closeness score for each node in the graph

        since

        0.0.101

        example
        const result = api.closeness(api.getLayoutGraph())
        view.applyTransform((graph) => {
        graph.getNodes().forEach(node => {
        node.properties.closeness = result.get(node.id)
        })
        return graph;
        })

        Parameters

        Returns ClosenessResult

  • collectNodes: ((options?: CollectNodesOptions) => TransformFunction)
      • Merge input nodes into new or existing collection nodes

        since

        0.0.149

        example
        // These are the same
        api.getLayoutGraph().applyTransform(
        api.collectNodes()
        )
        api.getLayoutGraph().applyTransform(
        api.collectNodes({
        nodes: api.getLayoutGraph().getNodes()
        })
        )
        api.getLayoutGraph().applyTransform(
        api.collectNodes({
        nodes: api.getLayoutGraph().getNodes().map(node => node.id)
        })
        )

        Parameters

        Returns TransformFunction

  • colorNodesByProperty: ((options: ColorNodesByPropertyOptions) => void)
      • Applies a color scale to all nodes by a certain property.

        since

        0.0.201

        example
        api.colorNodesByProperty({property: 'Episodes'});
        api.colorNodesByProperty({property: 'Episodes', scale: 'BuGn'});

        Parameters

        Returns void

  • comparePropertyValues: ((left: any, right: any, ascending?: boolean) => number)
      • (left: any, right: any, ascending?: boolean): number
      • Returns -1 if left < right, 0 if left == right, and 1 if left > right Flips the sign if ascending = false.

        Parameters

        • left: any
        • right: any
        • ascending: boolean = true

        Returns number

  • connectedComponent: ((graph: LayoutGraph) => ConnectedComponentResult)
  • convertToScreenCoordinates: ((position: Vector3) => Position)
  • createNodes: ((options: CreateNodesOptions) => TransformFunction)
      • Create nodes from an Array of raw node data. The raw node data is supplied as a list of dictionaries. Then an object with the following properties must be provided:

        • category: The category of the nodes to be created.
        • keys: The keys of the properties to be created.

        Parameters

        Returns TransformFunction

  • cube: ((options?: NodeFilterOptions) => LayoutFunction)
  • dijkstra: ((graph: LayoutGraph, options: DijkstraOptions) => Path[])
      • Returns all shortest paths from the source to target node.

        since

        0.95

        example
        const view = api.getLayoutGraph()
        const nodes = view.getNodes()
        const sourceId = nodes[0].id
        const targetId = nodes[nodes.length - 1].id
        const paths = api.dijkstra(view, {sourceId, targetId})
        // Optionally provide a custom weight property
        const weightProperty = 'weight_property'
        const paths = api.dijkstra(view, {sourceId, targetId, weightProperty})
        console.log(paths)
        // [[{nodeId: 'a', edgeId: 'ab'}, {nodeId: 'b'}]]

        Parameters

        Returns Path[]

  • dispatchGraphDataUpdate: (() => void)
      • (): void
      • Useful for forcing the UI to update after updating graph data.

        Returns void

  • distributionBy: ((options: DistributionOptions) => LayoutFunction)
      • Equally space Nodes on one of the x, y, or z axes while keeping the other two dimensions constant. Optionally bin the Nodes by a property value. Optionally scale the spacing by a "spread" factor (the higher the spread, the farther apart).

        since

        0.0.69

        example
        // Equally space Nodes on the x-axis
        GraphXR.getLayoutGraph().applyLayout(GraphXR.distributionBy({
        dimension: 'x', // y or z
        }))

        // Equally space Nodes on the x-axis and bin the Nodes by "seasonNumber"
        GraphXR.getLayoutGraph().applyLayout(GraphXR.distributionBy({
        bin: 'seasonNumber',
        dimension: 'x',
        }))

        // Equally space Nodes on the x-axis and bin the Nodes by "seasonNumber" in descending order
        GraphXR.getLayoutGraph().applyLayout(GraphXR.distributionBy({
        bin: 'seasonNumber',
        dimension: 'x',
        reverse: true,
        }))

        Parameters

        Returns LayoutFunction

  • edgesByRelationship: ((relationship: RelationshipId) => EdgeFilter)
  • ego: ((options: EgoOptions) => LayoutFunction)
      • Ego reveals hierarchal data by arranging nodes in a tree, where a node's depth in the tree is equal to the length of the shortest path to the node. The tree projects linearly in one direction, or radially around the root[s].

        since

        0.0.93

        example
        // The minimum requirements
        const graph = api.getLayoutGraph();
        graph.applyLayout(api.ego({
        filter: (node) => node.properties.Level === 1, // Find the root node[s]
        }));

        // Applying optional settings
        const graph = api.getLayoutGraph();
        graph.applyLayout(api.ego({
        depth: 3, // maximum depth of the tree; default 100
        edgeLength: 1 // visual length of the edges in the tree; default 0.2
        mode: 'rings' // 'tree' or 'rings'; default 'tree'
        orientation: 'down' // 'up', 'down', 'left', or 'right'; default 'right'
        sortByProperty: 'ComponentName' // arrange child nodes in ascending order by a property
        [sortByProperty: api.sortByProperty({property: "ComponentName", ascending: false})] // same as above, but descending
        }))

        Parameters

        Returns LayoutFunction

  • expandNodes: (() => Promise<ExpandNodesStatusCode>)
      • Queries Neo4j for nodes connected to the source nodes and then adds them to the graph.

        See ExpandNodesOptions for options.

        It returns a status code indicating whether there are more results available. See ExpandNodesStatusCode.

        since

        0.0.187

        example
        const status = await api.expandNodes({sourceNodeIds: ['1']});
        if (status === api.ExpandNodeStatusCode.MAYBE_MORE_RESULTS_AVAILABLE) {
        // call api.expandNodes with same parameters
        } else if (status === api.ExpandNodeStatusCode.NO_MORE_RESULTS_AVAILABLE) {
        // all done
        }

        Returns Promise<ExpandNodesStatusCode>

  • explodeCollections: ((options?: ExplodeCollectionsOptions) => TransformFunction)
      • For each collection node in the input, uncollect all nodes

        since

        0.0.153

        example
        // These are the same
        api.getLayoutGraph().applyTransform(
        api.explodeCollections()
        )
        api.getLayoutGraph().applyTransform(
        api.explodeCollections({
        nodes: api.getLayoutGraph().getNodes()
        })
        )
        api.getLayoutGraph().applyTransform(
        api.explodeCollections({
        nodes: api.getLayoutGraph().getNodes().map(node => node.id)
        })
        )

        Parameters

        Returns TransformFunction

  • extract: ((options: ExtractOptions) => TransformFunction)
      • Extract creates a new Category and Relationship linked to the input Nodes, based on the input prop options.

        since

        0.0.1

        example
        api.getLayoutGraph().applyTransform(api.extract({
        category: "Episodes",
        props: [
        {
        name: "seasonNumber",
        newName: "seasonNumber",
        isSplit: false,
        splitChar: "",
        isKey: true,
        },
        {
        name: "millionViewers",
        newName: "millionViewers",
        isSplit: false,
        splitChar: "",
        },
        {
        name: "episodeAirDate",
        newName: "episodeAirDate",
        isSplit: false,
        splitChar: "",
        },
        ],
        newCategory: "Season Number",
        newRelationship: "inSeason",
        inheritLinks: false,
        skipEmpty: true,
        }));

        Parameters

        Returns TransformFunction

  • flyToCenter: ((view?: LayoutGraph, nodeIds?: NodeId[], offset?: number, options?: TweenPositionOptions) => Promise<Position>)
      • Fly the camera to the center of a slice of nodes, optionally with an offset, optionally with a custom duration or tween function

        since

        0.0.139

        example
        // Center of all nodes
        api.flyToCenter();

        // Center of a slice of nodes
        const view = api.getLayoutGraph();
        const slice = view.getNodes().slice(0, 10).map(node => node.id);
        api.flyToCenter(view, slice);


        // Center of a slice of nodes with offset and duration
        const view = api.getLayoutGraph();
        const slice = view.getNodes().slice(0, 10).map(node => node.id);
        api.flyToCenter(view, slice, -3, { duration: 0 }););

        Parameters

        Returns Promise<Position>

  • flyToPosition: ((position: Vector3, offset?: number, options?: TweenPositionOptions) => Promise<Position>)
      • Fly the camera to a position, optionally with an offset, optionally with a custom duration or tween function

        since

        0.0.138

        example
        const view = api.getLayoutGraph();
        const firstNode = view.getNodes()[0];
        const position = firstNode.getStyle('position');
        api.flyToPosition(position); // no offset
        api.flyToPosition(position, -3); // with an offset
        api.flyToPosition(position, 0, { duration: 0 }); // instantly

        Parameters

        Returns Promise<Position>

  • getCategoryColor: ((categoryId: CategoryId) => Color)
  • getCategoryConfig: ((category: CategoryId) => CategoryConfig)
  • getGraphView: (() => void)
      • (): void
      • Returns void

  • getLayoutGraph: (() => LegacyLayoutGraph)
      • Returns a Graph which allows mutation of the Graph visualization.

        since

        0.0.1

        example
        const graph = api.getLayoutGraph();
        graph.addNodes([
        api.makeNode({category: "Episodes", properties: {episodeNumber: 1, seasonNumber: 1}}),
        ]);

        Returns LegacyLayoutGraph

  • getObservableLayoutGraph: ((options?: ObservableLayoutGraphOptions) => ObservableLayoutGraph)
      • Returns a Generator which resolves to the LegacyLayoutGraph. The Generator emits whenever the window global GraphXR owned GraphObservable object emits. It's useful in Grove to create cells which react to graph data changes.

        since

        0.0.231

        example
        // This is a Grove cell
        selectedNodes = api.getObservableLayoutGraph().getVisibleNodes().filter(node => node.getStyle("selected"));

        Parameters

        Returns ObservableLayoutGraph

  • getRuntime: (() => Runtime)
  • getScene: (() => THREE.Group)
      • (): THREE.Group
      • Returns a THREE.Group in which one can add new THREE objects to the 3d space

        since

        0.0.1

        example
        getScene().add(new THREE.DirectionalLight(0x404040));
        

        Returns THREE.Group

  • grid: ((options?: NodeFilterOptions) => LayoutFunction)
  • layout: ((computeLayout: LayoutNodesFunction, options?: NodeFilterOptions) => LayoutFunction)
  • line: ((options?: NodeFilterOptions) => LayoutFunction)
  • link: ((options: LinkOptions) => TransformFunction)
      • For each Node A in the source category, create an edge to a Node B in the target category, where A.sourceProperty === B.targetProperty

        since

        0.0.36

        example
        const graph = api.getLayoutGraph();
        graph.applyTransform(api.link({
        sourceCategory: "Roles",
        sourceProperty: "ParentName",
        targetCategory: "Roles",
        targetProperty: "ComponentName",
        relationship: "IS_PARENT_OF"
        }))

        Parameters

        Returns TransformFunction

  • louvain: ((graph: LayoutGraph) => LouvainResult)
  • makeCollectionNode: ((category: CategoryId, __namedParameters: NodeCollection) => ApiNode)
  • makeColor: ((hexOrR: number, g?: number, b?: number) => Color)
      • (hexOrR: number, g?: number, b?: number): Color
      • Parameters

        • hexOrR: number
        • Optional g: number
        • Optional b: number

        Returns Color

  • makeEdge: ((__namedParameters: Partial<ApiEdge>) => ApiEdge)
      • Creates an Edge object but does not add it to the graph space

        since

        0.0.1

        Parameters

        • __namedParameters: Partial<ApiEdge>

        Returns ApiEdge

  • makeGraph: (() => LayoutGraph)
  • makeNode: ((__namedParameters?: Partial<ApiNode>) => ApiNode)
      • Creates a Node object but does not add it to the graph space

        since

        0.0.1

        Parameters

        • __namedParameters: Partial<ApiNode> = {}

        Returns ApiNode

  • makeNodeId: (() => NodeId)
      • Creates a random NodeId

        since

        0.0.8

        Returns NodeId

  • makePosition: ((__namedParameters: Partial<Vector3>) => Position)
      • (__namedParameters: Partial<Vector3>): Position
      • Creates a Position (x,y,z)

        since

        0.0.1

        Parameters

        • __namedParameters: Partial<Vector3>

        Returns Position

  • makeRandomPosition: (() => Position)
  • map: ((options: MapOptions) => TransformFunction)
      • For each Node in the category, or each Edge in the relationship, map the mappedProperties using formula provided in the options. Optionally create a new name for the property.

        since

        0.0.35

        example
        // Convert every episodeAirDate property to a week value, in Nodes of the Episodes category
        map({
        category: 'Episode',
        mappedProperties: [
        {
        name: "episodeAirDate",
        newName: "newEpisodeAirDate",
        formula: GraphXR.mapFormula.toWeek,
        }
        ]
        })

        // Add 5 to every millionViewers property in Nodes belonging to the Episodes Category
        map({
        category: 'Episode',
        mappedProperties: [
        {
        name: "millionViewers",
        newName: "newMillionViewers",
        formula: (millionViewers, properties) => Number(millionViewers) + 1,
        }
        ]
        })

        // Add 1 to every seasonNumber property in Edges belonging to the inSeason Relationship
        map({
        relationship: 'inSeason',
        mappedProperties: [
        {
        name: "seasonNumber",
        newName: "newSeasonNumber",
        formula: (seasonNumber, properties) => Number(seasonNumber) + 1,
        }
        ]
        })

        Parameters

        Returns TransformFunction

  • mapFormula: { toDate: ((value: any) => string); toNumber: ((value: any) => number); toString: ((value: any) => string); toWeek: ((value: any) => string) }
    • toDate: ((value: any) => string)
        • (value: any): string
        • Parameters

          • value: any

          Returns string

    • toNumber: ((value: any) => number)
        • (value: any): number
        • Parameters

          • value: any

          Returns number

    • toString: ((value: any) => string)
        • (value: any): string
        • Parameters

          • value: any

          Returns string

    • toWeek: ((value: any) => string)
        • (value: any): string
        • Parameters

          • value: any

          Returns string

  • merge: ((options: MergeOptions) => TransformFunction)
      • Combine Nodes or Edges which have equivalent key properties.

        since

        0.0.37

        example
        // Combine all Nodes with equal seasonNumber into one Node
        merge({
        category: "Episodes",
        keyProperties: ['seasonNumber'],
        clearUnselectedProperties: false,
        })

        // Combine all emails between two persons sent on the same day (thus removing directionality)
        merge({
        relationship: "SENT_MAIL_TO"
        keyProperties: ['sendDate'],
        clearUnselectedProperties: false,
        })

        // Combine all emails between two persons sent on the same day and preserve directionality
        merge({
        relationship: "SENT_MAIL_TO"
        keyProperties: ['sendDate'],
        clearUnselectedProperties: false,
        directional: true,
        })

        Parameters

        Returns TransformFunction

  • mergeNodes: ((options: MergeNodesOptions) => TransformFunction)
      • Merge nodes from an Array of raw node data. The raw node data is supplied as a list of dictionaries. Then an object with the following properties must be provided:

        • category: The category of the nodes to be created.
        • keys: The keys of the properties to be created.
        • inputs: Tha JSON Objects to be created.

        Parameters

        Returns TransformFunction

  • mergeRelationships: ((options: MergeRelationshipsOptions) => TransformFunction)
      • Merge Relationships from an Array of raw node data. The raw node data is supplied as a list of dictionaries. Then an object with the following properties must be provided:

        • edge:
          • relationship: The keys of the properties to be merged.
          • keys: The keys of the properties to be merged.
        • source:
          • category: The category of the nodes to be merged.
          • keys: The keys of the properties to be merged.
        • target:
          • category: The category of the nodes to be merged.
          • keys: The keys of the properties to be merged.
        • inputs: Tha JSON Objects to be merged.

        Parameters

        Returns TransformFunction

  • neo4j: ((query: Neo4jQuery, options?: Neo4jOptions) => void)
      • Execute a Neo4j query. Results appear in the graph workspace

        since

        0.0.114

        example
        api.neo4j(`MATCH (n) RETURN n LIMIT 10`)
        

        Parameters

        Returns void

  • nodesByCategory: ((category: CategoryId) => NodeFilter)
      • Returns a function which, given a Node, returns true if the Node is in a certain category

        since

        0.0.41

        example
        aggregate({
        aggregateTo: nodesByCategory('Season'),
        aggregateAlong: "inSeason",
        getPropertyFrom: "node",
        sourceProperty: "millionViewers",
        targetProperty: "minMillionViewers",
        formula: "min",
        })

        Parameters

        Returns NodeFilter

  • observe: (<T>(event: GraphxrEvent, compute: ObserveCallback) => Iterator<T>)
      • Convert an async API event, like 'change', into an Iterator. Useful in Grove to define variables which react to data changes

        since

        0.0.53

        example
        personaNodes = observe(
        'change',
        () => api.getLayoutGraph().getNodes().filter(api.nodesByCategory('Persona'))
        )

        Type Parameters

        • T

        Parameters

        Returns Iterator<T>

  • on: ((event: GraphxrEvent, callback: GraphxrEventCallback, callbackId?: GraphxrEventCallbackId) => GraphxrEventCallbackId)
  • onChange: (<T>(cb: ObserveCallback) => Iterator<T, any, undefined>)
      • Convert graph data change into an observable Grove variable.

        since

        0.0.249

        example
        personaNodes = onChange(
        () => api.getLayoutGraph().getNodes().filter(api.nodesByCategory('Persona'))
        )

        Type Parameters

        • T

        Parameters

        Returns Iterator<T, any, undefined>

  • pageRank: ((graph: LayoutGraph, options?: PageRankOptions) => PageRankResult)
  • parametric: ((options: ParametricOptions) => LayoutFunction)
      • Map the x, y, and/or z dimensions to the range [-2, 2] by applying a linear scale to all or a subset of the domain of a property.

        If a dimension is omitted, it is flattened to align with the grid.

        since

        0.0.68

        example
        // Line up Nodes on the x-axis, ordered by seasonNumber.
        // Also set y and z to 0
        GraphXR.parametric({
        x: 'seasonNumber',
        y: 0,
        z: 0,
        })

        // Line up Nodes on the x-axis, ordered by seasonNumber descending. Align y and z to the grid.
        GraphXR.parametric({
        x: 'seasonNumber',
        reverse: true,
        })

        // Linearly scale seasonNumber, episodeNumber, and millionViewers on the x, y, and z dimensions respectively
        GraphXR.parametric({
        x: 'seasonNumber',
        y: 'episodeNumber',
        z: 'millionViewers',
        })

        Parameters

        Returns LayoutFunction

  • random: ((options?: NodeFilterOptions) => LayoutFunction)
  • rotate: ((options: RotateOptions) => LayoutFunction)
      • Given one of the x, y, or z dimensions, find the center point of all the Nodes and rotate all Nodes around the axis passing through the center point and lying on the dimension given.

        since

        0.0.72

        example
        GraphXR.rotate({
        dimension: 'x',
        theta: 90,
        })

        GraphXR.rotate({
        dimension: 'z',
        theta: 45
        })

        Parameters

        Returns LayoutFunction

  • scale: ((options?: ScaleOptions) => LayoutFunction)
      • Scale the distance of each node from a computed center by a constant factor.

        since

        0.0.90

        example
        // Expand a set of nodes from its center by a factor of 2
        GraphXR.scale({
        x: 2,
        y: 2,
        z: 2,
        })

        Parameters

        Returns LayoutFunction

  • setAutoShowImage: ((value: boolean) => boolean)
      • (value: boolean): boolean
      • Enable or disable auto-show image on Nodes.

        since

        0.0.138

        example
        api.setAutoShowImage(true);
        

        Parameters

        • value: boolean

        Returns boolean

  • setCameraOptions: ((options: CameraOptions) => void)
      • Set camera rotation, rotation axes visibility, camera speed

        since

        0.0.249

        example
        api.setCameraOptions({
        hideAxes: true,
        rotating: true,
        speed: 0.5,
        });

        Parameters

        Returns void

  • setCameraRotating: ((rotating: boolean) => void)
      • (rotating: boolean): void
      • Enable or disable rotating of the graph scene

        since

        0.0.138

        example
        api.setCameraRotating(true);
        

        Parameters

        • rotating: boolean

        Returns void

  • setCategoryCaptionProperties: ((__namedParameters: SetCategoryCaptionPropertiesOptions) => Promise<unknown>)
  • setCategorySizeProperty: ((__namedParameters: SetCategorySizePropertyOptions) => Promise<unknown>)
      • Set the property which will affect the size of the nodes in the category.

        since

        0.0.198

        example
        api.setCategorySizeProperty({category: 'Movie', property: 'released'});
        

        Parameters

        Returns Promise<unknown>

  • setEdgeScale: ((value: number) => number)
      • (value: number): number
      • Set the edge scale

        since

        0.0.138

        example
        api.setEdgeScale(5);
        

        Parameters

        • value: number

        Returns number

  • setFullscreen: ((value: boolean) => boolean)
      • (value: boolean): boolean
      • Hide panels and controls if fullscreen is enabled

        since

        0.0.138

        example
        api.setFullscreen(true);
        

        Parameters

        • value: boolean

        Returns boolean

  • setParametricAxesOptions: ((options: Partial<AxesOptions>) => void)
      • Sets the axes options. Parametric layout automatically sets these.

        since

        0.0.143

        example

        // Hide the axes api.setParametricAxesOptions({ showAxes: false, })

        Parameters

        Returns void

  • setRuntime: ((value: Runtime) => void)
      • An optional function which enables test runners to inject a mock Window object into the API. Most of the time, you won't call this function because the API runtime object defaults to window.

        since

        0.0.1

        Parameters

        • value: Runtime

          typically a mock of the Window

        Returns void

  • shift: ((options: ShiftOptions) => LayoutFunction)
  • shortcut: ((options: ShortcutOptions) => TransformFunction)
      • Given incomingRelationship, centerCategory, and outgoingRelationship, Shortcut finds all unique paths from node A to node C, traveling first along incomingRelationship, passing through centerCategory, and travelling lastly through outgoingRelationship to arrive at C. Once it finds all unique paths from A to C, Shortcut creates an edge A -> C with properties aggregated from the center nodes.

        Written differently, A -R0-> [B] -R1-> C => A -R2-> C where R0 is incomingRelationship, B is centerCategory, R1 is outgoingRelationship, and R2 is the new relationship. [B] means the set of all nodes B which are between A and C.

        since

        0.0.43

        example
        shortcut({
        incomingRelationship: 'IS_PARENT_OF',
        centerCategory: 'Node',
        outgoingRelationship: 'IS_PARENT_OF',
        shortcutRelationship: "IS_GRANDPARENT_OF",
        directional: true,
        aggregateProperties: [
        {
        sourceProperty: "age",
        targetProperty: "averageAge",
        formula: "average",
        },
        ],
        countLinks: false,
        })

        Parameters

        Returns TransformFunction

  • sleep: ((ms: number) => Promise<number>)
      • (ms: number): Promise<number>
      • Returns a promise that resolves after the given amount of milliseconds.

        since

        0.0.143

        example

        await sleep(1000); // Sleep for 1 second

        Parameters

        • ms: number

        Returns Promise<number>

  • sortByProperty: ((__namedParameters: SortByPropertyOptions) => Sort<ApiNode>)
  • spiral: ((options?: NodeFilterOptions) => LayoutFunction)
  • stronglyConnectedComponent: ((graph: LayoutGraph) => ConnectedComponentResult)
  • traceNeighbors: ((view: LayoutGraph, rootId: NodeId, options?: TraceNeighborsOptions) => MapPolyfill<NodeId, boolean>)
  • triggerForceLayout: (() => void)
      • (): void
      • Returns void

  • uncollectNodes: ((options?: UncollectNodesOptions) => TransformFunction)
      • Remove the input nodes from their collection nodes

        since

        0.0.153

        example
        // These are the same
        api.getLayoutGraph().applyTransform(
        api.uncollectNodes()
        )
        api.getLayoutGraph().applyTransform(
        api.uncollectNodes({
        nodes: api.getLayoutGraph().getNodes()
        })
        )
        api.getLayoutGraph().applyTransform(
        api.uncollectNodes({
        nodes: api.getLayoutGraph().getNodes().map(node => node.id)
        })
        )

        Parameters

        Returns TransformFunction

Other Variables

AXES: { x: Vector3; y: Vector3; z: Vector3 } = ...

Type declaration

  • x: Vector3
  • y: Vector3
  • z: Vector3
DEFAULT_CATEGORY_ID: CategoryId = ...
DEFAULT_RELATIONSHIP_ID: RelationshipId = ...
DIMENSIONS: Record<Dimension, Dimension> = ...
EDGE_STYLES: EdgeStyle[] = ...
GRAPHXR_API_VERSION: "0.0.253" = '0.0.253'
MINIMUM_GRAPHXR_VERSION: "2.11.0" = "2.11.0"

GraphXR must be this version or greater. See package.json in the root directory of the graph repository.

NODE_STYLES: NodeStyle[] = ...
defaultLinkOptions: { relationship: RelationshipId } = ...

Type declaration

mapFormula: { toDate: ((value: any) => string); toNumber: ((value: any) => number); toString: ((value: any) => string); toWeek: ((value: any) => string) } = ...

Type declaration

  • toDate: ((value: any) => string)
      • (value: any): string
      • Parameters

        • value: any

        Returns string

  • toNumber: ((value: any) => number)
      • (value: any): number
      • Parameters

        • value: any

        Returns number

  • toString: ((value: any) => string)
      • (value: any): string
      • Parameters

        • value: any

        Returns string

  • toWeek: ((value: any) => string)
      • (value: any): string
      • Parameters

        • value: any

        Returns string

runtime: Runtime

Algorithm Functions

Camera Functions

  • Fly the camera to the center of a slice of nodes, optionally with an offset, optionally with a custom duration or tween function

    since

    0.0.139

    example
    // Center of all nodes
    api.flyToCenter();

    // Center of a slice of nodes
    const view = api.getLayoutGraph();
    const slice = view.getNodes().slice(0, 10).map(node => node.id);
    api.flyToCenter(view, slice);


    // Center of a slice of nodes with offset and duration
    const view = api.getLayoutGraph();
    const slice = view.getNodes().slice(0, 10).map(node => node.id);
    api.flyToCenter(view, slice, -3, { duration: 0 }););

    Parameters

    Returns Promise<Position>

  • Fly the camera to a position, optionally with an offset, optionally with a custom duration or tween function

    since

    0.0.138

    example
    const view = api.getLayoutGraph();
    const firstNode = view.getNodes()[0];
    const position = firstNode.getStyle('position');
    api.flyToPosition(position); // no offset
    api.flyToPosition(position, -3); // with an offset
    api.flyToPosition(position, 0, { duration: 0 }); // instantly

    Parameters

    Returns Promise<Position>

  • Set camera rotation, rotation axes visibility, camera speed

    since

    0.0.249

    example
    api.setCameraOptions({
    hideAxes: true,
    rotating: true,
    speed: 0.5,
    });

    Parameters

    Returns void

  • setCameraRotating(rotating: boolean): void
  • Enable or disable rotating of the graph scene

    since

    0.0.138

    example
    api.setCameraRotating(true);
    

    Parameters

    • rotating: boolean

    Returns void

Category Functions

Centrality Functions

  • Compute Betweenness score for each node in the graph

    since

    0.0.100

    example
    const result = api.betweenness(api.getLayoutGraph())
    view.applyTransform((graph) => {
    graph.getNodes().forEach(node => {
    node.properties.betweenness = result.get(node.id)
    })
    return graph;
    })

    Parameters

    Returns BetweennessResult

  • Compute Closeness score for each node in the graph

    since

    0.0.101

    example
    const result = api.closeness(api.getLayoutGraph())
    view.applyTransform((graph) => {
    graph.getNodes().forEach(node => {
    node.properties.closeness = result.get(node.id)
    })
    return graph;
    })

    Parameters

    Returns ClosenessResult

  • Compute PageRank for the entire graph

    since

    0.0.98

    example
    const result = GraphXR.pageRank()
    view.applyTransform((graph) => {
    graph.getNodes().forEach(node => {
    node.properties.pageRank = result.get(node.id)
    })
    return graph;
    })

    Parameters

    Returns PageRankResult

Community Detection Functions

Edge Functions

  • Creates an Edge object but does not add it to the graph space

    since

    0.0.1

    Parameters

    • __namedParameters: Partial<ApiEdge>

    Returns ApiEdge

Events Functions

  • Convert an async API event, like 'change', into an Iterator. Useful in Grove to define variables which react to data changes

    since

    0.0.53

    example
    personaNodes = observe(
    'change',
    () => api.getLayoutGraph().getNodes().filter(api.nodesByCategory('Persona'))
    )

    Type Parameters

    • T

    Parameters

    Returns Iterator<T>

  • Convert graph data change into an observable Grove variable.

    since

    0.0.249

    example
    personaNodes = onChange(
    () => api.getLayoutGraph().getNodes().filter(api.nodesByCategory('Persona'))
    )

    Type Parameters

    • T

    Parameters

    Returns Iterator<T, any, undefined>

Filter Functions

  • Returns a function which, given a Node, returns true if the Node is in a certain category

    since

    0.0.41

    example
    aggregate({
    aggregateTo: nodesByCategory('Season'),
    aggregateAlong: "inSeason",
    getPropertyFrom: "node",
    sourceProperty: "millionViewers",
    targetProperty: "minMillionViewers",
    formula: "min",
    })

    Parameters

    Returns NodeFilter

Graph Functions

  • Returns a Graph which allows mutation of the Graph visualization.

    since

    0.0.1

    example
    const graph = api.getLayoutGraph();
    graph.addNodes([
    api.makeNode({category: "Episodes", properties: {episodeNumber: 1, seasonNumber: 1}}),
    ]);

    Returns LegacyLayoutGraph

Grove Functions

  • Returns a Generator which resolves to the LegacyLayoutGraph. The Generator emits whenever the window global GraphXR owned GraphObservable object emits. It's useful in Grove to create cells which react to graph data changes.

    since

    0.0.231

    example
    // This is a Grove cell
    selectedNodes = api.getObservableLayoutGraph().getVisibleNodes().filter(node => node.getStyle("selected"));

    Parameters

    Returns ObservableLayoutGraph

Layout Functions

  • Given one of x, y, or z, find the center of that dimension and align all Nodes to that center on that dimension only.

    since

    0.0.70

    example
    GraphXR.alignBy({
    dimension: 'x',
    })

    Parameters

    Returns LayoutFunction

  • Sets the positions of Nodes. Optionally animate the position. If tween provided with the LayoutResult, use it. Override the default tweens returned by (for example) line() and circle() by providing TweenLayoutOverrides. If tween is undefined, set all the positions immediately

    since

    0.0.1

    example
    // Basic example
    GraphXR.applyLayout(GraphXR.getLayoutGraph(), GraphXR.line())

    // Layouts can be tweened, or not.
    GraphXR.applyLayout(GraphXR.getLayoutGraph(), GraphXR.circle(), {duration: 3000})
    GraphXR.applyLayout(GraphXR.getLayoutGraph(), GraphXR.cube(), {duration: 3000, interpolate: myInterpolate})

    // Define your own layout!
    GraphXR.applyLayout(
    GraphXR.getLayoutGraph(),
    {
    final: new Map(GraphXR.getNodes().map(n => [n, GraphXR.makeRandomPosition()])),
    tween: {
    duration: 3000,
    interpolate: myInterpolate,
    }
    }
    )

    // Sort and Filter can apply to the geometric layouts.
    // Also, note that you can call applyLayout on a LayoutGraph.
    GraphXR.getLayoutGraph().applyLayout(
    GraphXR.line({
    sort: 'price', // shorthand for GraphXR.sortByProperty({property: 'price', ascending: true})
    filter: GraphXR.nodesByCategory('Item'),
    })
    ))

    Parameters

    Returns Promise<NodeIdToPosition>

  • Equally space Nodes on one of the x, y, or z axes while keeping the other two dimensions constant. Optionally bin the Nodes by a property value. Optionally scale the spacing by a "spread" factor (the higher the spread, the farther apart).

    since

    0.0.69

    example
    // Equally space Nodes on the x-axis
    GraphXR.getLayoutGraph().applyLayout(GraphXR.distributionBy({
    dimension: 'x', // y or z
    }))

    // Equally space Nodes on the x-axis and bin the Nodes by "seasonNumber"
    GraphXR.getLayoutGraph().applyLayout(GraphXR.distributionBy({
    bin: 'seasonNumber',
    dimension: 'x',
    }))

    // Equally space Nodes on the x-axis and bin the Nodes by "seasonNumber" in descending order
    GraphXR.getLayoutGraph().applyLayout(GraphXR.distributionBy({
    bin: 'seasonNumber',
    dimension: 'x',
    reverse: true,
    }))

    Parameters

    Returns LayoutFunction

  • Ego reveals hierarchal data by arranging nodes in a tree, where a node's depth in the tree is equal to the length of the shortest path to the node. The tree projects linearly in one direction, or radially around the root[s].

    since

    0.0.93

    example
    // The minimum requirements
    const graph = api.getLayoutGraph();
    graph.applyLayout(api.ego({
    filter: (node) => node.properties.Level === 1, // Find the root node[s]
    }));

    // Applying optional settings
    const graph = api.getLayoutGraph();
    graph.applyLayout(api.ego({
    depth: 3, // maximum depth of the tree; default 100
    edgeLength: 1 // visual length of the edges in the tree; default 0.2
    mode: 'rings' // 'tree' or 'rings'; default 'tree'
    orientation: 'down' // 'up', 'down', 'left', or 'right'; default 'right'
    sortByProperty: 'ComponentName' // arrange child nodes in ascending order by a property
    [sortByProperty: api.sortByProperty({property: "ComponentName", ascending: false})] // same as above, but descending
    }))

    Parameters

    Returns LayoutFunction

  • Map the x, y, and/or z dimensions to the range [-2, 2] by applying a linear scale to all or a subset of the domain of a property.

    If a dimension is omitted, it is flattened to align with the grid.

    since

    0.0.68

    example
    // Line up Nodes on the x-axis, ordered by seasonNumber.
    // Also set y and z to 0
    GraphXR.parametric({
    x: 'seasonNumber',
    y: 0,
    z: 0,
    })

    // Line up Nodes on the x-axis, ordered by seasonNumber descending. Align y and z to the grid.
    GraphXR.parametric({
    x: 'seasonNumber',
    reverse: true,
    })

    // Linearly scale seasonNumber, episodeNumber, and millionViewers on the x, y, and z dimensions respectively
    GraphXR.parametric({
    x: 'seasonNumber',
    y: 'episodeNumber',
    z: 'millionViewers',
    })

    Parameters

    Returns LayoutFunction

  • Given one of the x, y, or z dimensions, find the center point of all the Nodes and rotate all Nodes around the axis passing through the center point and lying on the dimension given.

    since

    0.0.72

    example
    GraphXR.rotate({
    dimension: 'x',
    theta: 90,
    })

    GraphXR.rotate({
    dimension: 'z',
    theta: 45
    })

    Parameters

    Returns LayoutFunction

  • Scale the distance of each node from a computed center by a constant factor.

    since

    0.0.90

    example
    // Expand a set of nodes from its center by a factor of 2
    GraphXR.scale({
    x: 2,
    y: 2,
    z: 2,
    })

    Parameters

    Returns LayoutFunction

  • setParametricAxesOptions(options: Partial<AxesOptions>): void
  • Sets the axes options. Parametric layout automatically sets these.

    since

    0.0.143

    example

    // Hide the axes api.setParametricAxesOptions({ showAxes: false, })

    Parameters

    Returns void

Legend Functions

  • Applies a color scale to all nodes by a certain property.

    since

    0.0.201

    example
    api.colorNodesByProperty({property: 'Episodes'});
    api.colorNodesByProperty({property: 'Episodes', scale: 'BuGn'});

    Parameters

    Returns void

Neo4j Functions

  • Queries Neo4j for nodes connected to the source nodes and then adds them to the graph.

    See ExpandNodesOptions for options.

    It returns a status code indicating whether there are more results available. See ExpandNodesStatusCode.

    since

    0.0.187

    example
    const status = await api.expandNodes({sourceNodeIds: ['1']});
    if (status === api.ExpandNodeStatusCode.MAYBE_MORE_RESULTS_AVAILABLE) {
    // call api.expandNodes with same parameters
    } else if (status === api.ExpandNodeStatusCode.NO_MORE_RESULTS_AVAILABLE) {
    // all done
    }

    Returns Promise<ExpandNodesStatusCode>

  • Execute a Neo4j query. Results appear in the graph workspace

    since

    0.0.114

    example
    api.neo4j(`MATCH (n) RETURN n LIMIT 10`)
    

    Parameters

    Returns void

  • Converts a Neo4j Graph response to a Graph, which we can merge into the graph workspace.

    since

    0.0.130

    example
    api.getLayoutGraph().assign((await api.neo4j(`MATCH (p:Person {name: 'Kevin Bacon'})-[d:ACTED_IN *1..3]-(hollywood) return DISTINCT p, hollywood, d`)).toGraph());
    

    Parameters

    Returns LayoutGraph

Node Functions

  • Creates a Node object but does not add it to the graph space

    since

    0.0.1

    Parameters

    • __namedParameters: Partial<ApiNode> = {}

    Returns ApiNode

Other Functions

  • Create nodes from an Array of raw node data. The raw node data is supplied as a list of dictionaries. Then an object with the following properties must be provided:

    • category: The category of the nodes to be created.
    • keys: The keys of the properties to be created.

    Parameters

    Returns TransformFunction

  • dispatchGraphDataUpdate(): void
  • findGraphXRWindow(): Window | undefined
  • makeColor(hexOrR: number, g?: number, b?: number): Color
  • Parameters

    • hexOrR: number
    • Optional g: number
    • Optional b: number

    Returns Color

  • Merge nodes from an Array of raw node data. The raw node data is supplied as a list of dictionaries. Then an object with the following properties must be provided:

    • category: The category of the nodes to be created.
    • keys: The keys of the properties to be created.
    • inputs: Tha JSON Objects to be created.

    Parameters

    Returns TransformFunction

  • Merge Relationships from an Array of raw node data. The raw node data is supplied as a list of dictionaries. Then an object with the following properties must be provided:

    • edge:
      • relationship: The keys of the properties to be merged.
      • keys: The keys of the properties to be merged.
    • source:
      • category: The category of the nodes to be merged.
      • keys: The keys of the properties to be merged.
    • target:
      • category: The category of the nodes to be merged.
      • keys: The keys of the properties to be merged.
    • inputs: Tha JSON Objects to be merged.

    Parameters

    Returns TransformFunction

  • triggerForceLayout(): void

Path Finding Functions

  • Returns all shortest paths from the source to target node.

    since

    0.95

    example
    const view = api.getLayoutGraph()
    const nodes = view.getNodes()
    const sourceId = nodes[0].id
    const targetId = nodes[nodes.length - 1].id
    const paths = api.dijkstra(view, {sourceId, targetId})
    // Optionally provide a custom weight property
    const weightProperty = 'weight_property'
    const paths = api.dijkstra(view, {sourceId, targetId, weightProperty})
    console.log(paths)
    // [[{nodeId: 'a', edgeId: 'ab'}, {nodeId: 'b'}]]

    Parameters

    Returns Path[]

Project Settings Functions

  • setAutoShowImage(value: boolean): boolean
  • Enable or disable auto-show image on Nodes.

    since

    0.0.138

    example
    api.setAutoShowImage(true);
    

    Parameters

    • value: boolean

    Returns boolean

  • setEdgeScale(value: number): number
  • Set the edge scale

    since

    0.0.138

    example
    api.setEdgeScale(5);
    

    Parameters

    • value: number

    Returns number

Properties Functions

  • comparePropertyValues(left: any, right: any, ascending?: boolean): number
  • Returns -1 if left < right, 0 if left == right, and 1 if left > right Flips the sign if ascending = false.

    Parameters

    • left: any
    • right: any
    • ascending: boolean = true

    Returns number

Render Functions

  • getScene(): THREE.Group
  • Returns a THREE.Group in which one can add new THREE objects to the 3d space

    since

    0.0.1

    example
    getScene().add(new THREE.DirectionalLight(0x404040));
    

    Returns THREE.Group

Runtime Functions

  • An optional function which enables test runners to inject a mock Window object into the API. Most of the time, you won't call this function because the API runtime object defaults to window.

    since

    0.0.1

    Parameters

    • value: Runtime

      typically a mock of the Window

    Returns void

Sort Functions

Style Functions

  • makePosition(__namedParameters: Partial<Vector3>): Position
  • Creates a Position (x,y,z)

    since

    0.0.1

    Parameters

    • __namedParameters: Partial<Vector3>

    Returns Position

Transform Functions

  • For each Node in the aggregateTo Category, collect the value of the targetProperty from every neighbor of that Node connected by an Edge of the aggregateAlong Relationship into an array. Then, run a mapping function formula on the array and store the resulting value in a property of the Node.

    since

    0.0.25

    example
    // For each Season Node, make a new property "episodeNumbers" which is a concatentation of all the
    // episodeNumber property values from Episodes connected to the Season along the inSeason relationship
    api.getLayoutGraph().applyTransform(api.aggregate({
    aggregateTo: 'Season',
    aggregateAlong: 'inSeason',
    getPropertyFrom: 'node',
    sourceProperty: 'episodeNumber',
    targetProperty: 'episodeNumbers',
    formula: 'concatenate'
    }))

    // For each Season Node, make a new property "maxEpisodeNumber" which is the maximum of all the
    // episodeNumber property values from inSeason edges connected to the Season.
    api.getLayoutGraph().applyTransform(api.aggregate({
    aggregateTo: 'Season',
    aggregateAlong: 'inSeason',
    getPropertyFrom: 'edge',
    sourceProperty: 'episodeNumber',
    targetProperty: 'maxEpisodeNumber',
    formula: 'max'
    }))

    // aggregateTo can be a function, a category, an array of nodes, or an array of node ids
    api.getLayoutGraph().applyTransform(api.aggregate({
    // function
    aggregateTo: node => node.category === 'Season',
    // category
    aggregateTo: 'Season',
    // array of nodes
    aggregateTo: api.getLayoutGraph().getNodes().filter(node => node.category === 'Season'),
    // array of node ids
    aggregateTo: api.getLayoutGraph().getNodes().filter(node => node.category === 'Season').map(node => node.id),
    }))

    // formula can be a function or a string
    api.getLayoutGraph().applyTransform(api.aggregate({
    // function
    formula: (values) => values.reduce((a, b) => a + b, 0),
    // string
    formula: 'sum',
    }))

    Parameters

    Returns TransformFunction

  • Merge input nodes into new or existing collection nodes

    since

    0.0.149

    example
    // These are the same
    api.getLayoutGraph().applyTransform(
    api.collectNodes()
    )
    api.getLayoutGraph().applyTransform(
    api.collectNodes({
    nodes: api.getLayoutGraph().getNodes()
    })
    )
    api.getLayoutGraph().applyTransform(
    api.collectNodes({
    nodes: api.getLayoutGraph().getNodes().map(node => node.id)
    })
    )

    Parameters

    Returns TransformFunction

  • For each collection node in the input, uncollect all nodes

    since

    0.0.153

    example
    // These are the same
    api.getLayoutGraph().applyTransform(
    api.explodeCollections()
    )
    api.getLayoutGraph().applyTransform(
    api.explodeCollections({
    nodes: api.getLayoutGraph().getNodes()
    })
    )
    api.getLayoutGraph().applyTransform(
    api.explodeCollections({
    nodes: api.getLayoutGraph().getNodes().map(node => node.id)
    })
    )

    Parameters

    Returns TransformFunction

  • Extract creates a new Category and Relationship linked to the input Nodes, based on the input prop options.

    since

    0.0.1

    example
    api.getLayoutGraph().applyTransform(api.extract({
    category: "Episodes",
    props: [
    {
    name: "seasonNumber",
    newName: "seasonNumber",
    isSplit: false,
    splitChar: "",
    isKey: true,
    },
    {
    name: "millionViewers",
    newName: "millionViewers",
    isSplit: false,
    splitChar: "",
    },
    {
    name: "episodeAirDate",
    newName: "episodeAirDate",
    isSplit: false,
    splitChar: "",
    },
    ],
    newCategory: "Season Number",
    newRelationship: "inSeason",
    inheritLinks: false,
    skipEmpty: true,
    }));

    Parameters

    Returns TransformFunction

  • For each Node A in the source category, create an edge to a Node B in the target category, where A.sourceProperty === B.targetProperty

    since

    0.0.36

    example
    const graph = api.getLayoutGraph();
    graph.applyTransform(api.link({
    sourceCategory: "Roles",
    sourceProperty: "ParentName",
    targetCategory: "Roles",
    targetProperty: "ComponentName",
    relationship: "IS_PARENT_OF"
    }))

    Parameters

    Returns TransformFunction

  • For each Node in the category, or each Edge in the relationship, map the mappedProperties using formula provided in the options. Optionally create a new name for the property.

    since

    0.0.35

    example
    // Convert every episodeAirDate property to a week value, in Nodes of the Episodes category
    map({
    category: 'Episode',
    mappedProperties: [
    {
    name: "episodeAirDate",
    newName: "newEpisodeAirDate",
    formula: GraphXR.mapFormula.toWeek,
    }
    ]
    })

    // Add 5 to every millionViewers property in Nodes belonging to the Episodes Category
    map({
    category: 'Episode',
    mappedProperties: [
    {
    name: "millionViewers",
    newName: "newMillionViewers",
    formula: (millionViewers, properties) => Number(millionViewers) + 1,
    }
    ]
    })

    // Add 1 to every seasonNumber property in Edges belonging to the inSeason Relationship
    map({
    relationship: 'inSeason',
    mappedProperties: [
    {
    name: "seasonNumber",
    newName: "newSeasonNumber",
    formula: (seasonNumber, properties) => Number(seasonNumber) + 1,
    }
    ]
    })

    Parameters

    Returns TransformFunction

  • Combine Nodes or Edges which have equivalent key properties.

    since

    0.0.37

    example
    // Combine all Nodes with equal seasonNumber into one Node
    merge({
    category: "Episodes",
    keyProperties: ['seasonNumber'],
    clearUnselectedProperties: false,
    })

    // Combine all emails between two persons sent on the same day (thus removing directionality)
    merge({
    relationship: "SENT_MAIL_TO"
    keyProperties: ['sendDate'],
    clearUnselectedProperties: false,
    })

    // Combine all emails between two persons sent on the same day and preserve directionality
    merge({
    relationship: "SENT_MAIL_TO"
    keyProperties: ['sendDate'],
    clearUnselectedProperties: false,
    directional: true,
    })

    Parameters

    Returns TransformFunction

  • Given incomingRelationship, centerCategory, and outgoingRelationship, Shortcut finds all unique paths from node A to node C, traveling first along incomingRelationship, passing through centerCategory, and travelling lastly through outgoingRelationship to arrive at C. Once it finds all unique paths from A to C, Shortcut creates an edge A -> C with properties aggregated from the center nodes.

    Written differently, A -R0-> [B] -R1-> C => A -R2-> C where R0 is incomingRelationship, B is centerCategory, R1 is outgoingRelationship, and R2 is the new relationship. [B] means the set of all nodes B which are between A and C.

    since

    0.0.43

    example
    shortcut({
    incomingRelationship: 'IS_PARENT_OF',
    centerCategory: 'Node',
    outgoingRelationship: 'IS_PARENT_OF',
    shortcutRelationship: "IS_GRANDPARENT_OF",
    directional: true,
    aggregateProperties: [
    {
    sourceProperty: "age",
    targetProperty: "averageAge",
    formula: "average",
    },
    ],
    countLinks: false,
    })

    Parameters

    Returns TransformFunction

  • Remove the input nodes from their collection nodes

    since

    0.0.153

    example
    // These are the same
    api.getLayoutGraph().applyTransform(
    api.uncollectNodes()
    )
    api.getLayoutGraph().applyTransform(
    api.uncollectNodes({
    nodes: api.getLayoutGraph().getNodes()
    })
    )
    api.getLayoutGraph().applyTransform(
    api.uncollectNodes({
    nodes: api.getLayoutGraph().getNodes().map(node => node.id)
    })
    )

    Parameters

    Returns TransformFunction

Utility Functions

  • sleep(ms: number): Promise<number>
  • Returns a promise that resolves after the given amount of milliseconds.

    since

    0.0.143

    example

    await sleep(1000); // Sleep for 1 second

    Parameters

    • ms: number

    Returns Promise<number>

window Functions

  • setFullscreen(value: boolean): boolean
  • Hide panels and controls if fullscreen is enabled

    since

    0.0.138

    example
    api.setFullscreen(true);
    

    Parameters

    • value: boolean

    Returns boolean

Generated using TypeDoc