Skip to content

Instantly share code, notes, and snippets.

@ChadJPetersen
Created August 3, 2020 22:29
Show Gist options
  • Save ChadJPetersen/2e2587bbd753c6a384c02519183e2031 to your computer and use it in GitHub Desktop.
Save ChadJPetersen/2e2587bbd753c6a384c02519183e2031 to your computer and use it in GitHub Desktop.
//You must first install the vis and react types 'npm install --save-dev @types/vis @types/react'
declare module "react-graph-vis" {
import { Network, NetworkEvents, Options, Node, Edge, DataSet } from "vis";
import { Component } from "react";
export { Network, NetworkEvents, Options, Node, Edge, DataSet } from "vis";
export interface graphEvents {
[event: NetworkEvents]: (params?: any) => void;
}
//Doesn't appear that this module supports passing in a vis.DataSet directly. Once it does graph can just use the Data object from vis.
export interface graphData {
nodes: Node[];
edges: Edge[];
}
export interface NetworkGraphProps {
graph: graphData;
options?: Options;
events?: graphEvents;
getNetwork?: (network: Network) => void;
identifier?: string;
style?: React.CSSProperties;
getNodes?: (nodes: DataSet) => void;
getEdges?: (edges: DataSet) => void;
}
export interface NetworkGraphState {
identifier: string;
}
export default class NetworkGraph extends Component<
NetworkGraphProps,
NetworkGraphState
> {
render();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment