Function: logoLayer()
logoLayer(
o):NivoLayer
Defined in: packages/sdvplot/src/nivo.ts:216
Team logos as a nivo custom layer: add it to a chart's layers, after the built-in ones it should sit over.
- Bump: a logo at each series' last point (
atpicks the first, or every point), the team read from the series'id(or itsteamfield). - SwarmPlot: a logo at every node, the team read from the node's
id(or its datum'steamfield). - Chord: a logo outside the ring at the middle of each arc, the team read from the arc's id (the chart's
keys).
Logos are height × the plot height tall. Given your own layers, put the logo layer before "mesh"; appended after
it, it is harmless (its group has pointer-events: none, so the mesh still gets the mouse). A team with no logo draws nothing and warns once, as sdvplot/echarts
does. The logos sit at nivo's final positions: they do not tween with animate.
Parameters
o
Returns
Example
import { SwarmPlot } from "@nivo/swarmplot";
import { loadLeague } from "@sportsdataverse/sdvplot";
import { logoLayer, teamColors } from "@sportsdataverse/sdvplot/nivo";
await loadLeague("nfl");
const rows = [
{ team: "KC", pf: 385 },
{ team: "LAC", pf: 402 },
{ team: "DEN", pf: 425 },
];
<SwarmPlot
width={500}
height={200}
data={rows.map((r) => ({ ...r, group: "AFC West" }))}
groups={["AFC West"]}
id="team"
value="pf"
size={10}
colors={teamColors({ league: "nfl" })}
layers={["grid", "axes", "circles", logoLayer({ league: "nfl", height: 0.2 })]}
/>;