Generates a D3 compatible node-link structure from a data frame (array of objects).
dataArray array of objects containing the data.keys(Object | Array) object of {key: column/accessor} pairs or an array of [key, column/accessor] pairsvaluesObject object of accessor functions for link values. (optional, default{})
const data = [
{ Country: "USA", Religion: "Christian" },
{ Country: "UK", Religion: "Christian" },
{ Country: "Iran", Religion: "Muslim" },
];
// List nodes to extract from each row
const keys = {
Country: "Country", // Create node from "Country" field
Religion: (d) => d.Religion, // Create node from "Religion" field
};
// Define attributes to add to each node / link
const values = {
count: 1, // Sum "1" to count the number of rows matching each node / link
Population: "Population", // Sum the "Population" field from rows matching each node / link
};
const { nodes, links } = kpartite(data, keys, values);Returns NodeLink { nodes, links } arrays with the node-link structure.
Type: Object
-
nodesArray unique nodes for each key in each data element -
linksArray unique links for each PAIR of keys in each data element
Creates a network visualization.
-
el(string | HTMLElement) The selector or HTML element for the SVG. -
paramsObject Parameters for the visualization.params.nodesArray list of node objects.params.linksArray list of {source, target} link objects.params.widthnumber? width of the SVG.params.heightnumber? height of the SVG.params.linkCurvaturenumber curvature of the links. 0 = straight, 1 = half-circle. (optional, default0)params.nodeTagstring SVG tag to use for nodes. (optional, default"circle")params.forcesObject? forces to apply to the simulation.params.brushFunction? callback function to handle brush events.params.idstring? unique identifier for the simulation. Usesel.idif not specified.params.d3Object D3 instance to use. (optional, defaultwindow.d3)
Returns Graph Object containing D3.js selections for nodes and links.
Define the returned graph
Type: Object