Skip to main content

Function: logoTickLabel()

logoTickLabel(o): MuiTickLabelSlot

Defined in: packages/sdvplot/src/mui.ts:527

Team logos as an axis' tick labels: <ChartsXAxis slots={{ axisTickLabel: logoTickLabel({ league }) }} /> on a band axis whose values are teams. The logo sits where MUI would put the label (under a bottom axis, left of a left one), size px tall; give the axis room for it (an x axis' height, a y axis' width). A label that resolves to no logo keeps its text and warns once, as sdvplot/echarts' withAxisLogos does. The label is the axis' formatted value, so a valueFormatter must keep it a team (abbreviation, name or id).

Give it to the team axis alone, as a prop of the composition API's <ChartsXAxis> / <ChartsYAxis>: a chart's slots reach every axis (a value axis' label "12" would resolve as team id 12), and in @mui/x-charts 9.15 the slots of an axis in the xAxis prop are dropped by BarChart and the other single-component charts.

Parameters​

o​

MuiTickLabelOptions

Returns​

MuiTickLabelSlot

Example​

import { BarPlot } from "@mui/x-charts/BarChart";
import { ChartsContainer } from "@mui/x-charts/ChartsContainer";
import { ChartsXAxis } from "@mui/x-charts/ChartsXAxis";
import { ChartsYAxis } from "@mui/x-charts/ChartsYAxis";
import { loadLeague } from "@sportsdataverse/sdvplot";
import { logoTickLabel } from "@sportsdataverse/sdvplot/mui";

await loadLeague("nfl");
const teams = ["KC", "BUF", "BAL"];
<ChartsContainer
width={400}
height={260}
xAxis={[{ id: "teams", scaleType: "band", data: teams, height: 40 }]}
yAxis={[{ id: "wins" }]}
series={[{ type: "bar", data: [15, 13, 12] }]}
>
<BarPlot />
<ChartsXAxis axisId="teams" slots={{ axisTickLabel: logoTickLabel({ league: "nfl", size: 28 }) }} />
<ChartsYAxis axisId="wins" />
</ChartsContainer>;