Skip to main content

passNetwork

https://a.espncdn.com/combiner/i?img=/i/headshots/nfl/players/full/3139477.png
import { loadLeague } from "@sportsdataverse/sdvplot";
import { passNetwork } from "@sportsdataverse/sdvplot/cytoscape";

await loadLeague("nfl");
// Patrick Mahomes to Xavier Worthy, a Super Bowl LIX touchdown (ESPN athlete ids)
const pass = { from: 3139477, from_name: "Patrick Mahomes", to: 4683062, to_name: "Xavier Worthy", team: "KC" };
const { elements, style } = passNetwork([pass], {
from: "from",
to: "to",
fromName: "from_name",
toName: "to_name",
team: "team",
league: "nfl",
});
// in the browser: cytoscape({ container, elements, style, layout: { name: "cose" } })
elements.nodes[0]?.data.image;

Tags: docstring · passNetwork. All sdvplot examples.