Titles
Since 0.1.0-alpha.22A chart's title, or a heading on the page that titles it, such as a card's, so the title isn't written twice, and the title's size and alignment.
Titled by a heading
When a heading on the page already says what the chart shows, such as a card's title, set TitledBy to the heading's id instead of giving the chart a Title. A Card gives its heading an id with TitleId.
Static
Preview
New signups, last 7 days
Trials and paid plans
- Trials
- Paid
0100200300
MonTueWedThuFriSatSun
Mon
Trials
142
Paid
31
Tue
Trials
168
Paid
38
Wed
Trials
155
Paid
35
Thu
Trials
171
Paid
42
Fri
Trials
149
Paid
33
Sat
Trials
88
Paid
14
Sun
Trials
79
Paid
12
| Day | Trials | Paid |
|---|---|---|
| Mon | 142 | 31 |
| Tue | 168 | 38 |
| Wed | 155 | 35 |
| Thu | 171 | 42 |
| Fri | 149 | 33 |
| Sat | 88 | 14 |
| Sun | 79 | 12 |
Code
@* A dashboard card whose heading titles the chart: the chart takes its name from it and shows no
title of its own. *@
<Card Title="New signups, last 7 days" TitleId="signups-heading" Description="Trials and paid plans" Width="Length.Full" MaxWidth="32.Rem">
<Chart Items="_days" Argument="d => d.Day" TitledBy="signups-heading" Stacking="ChartStacking.Normal" Height="12.Rem">
<ChartBarSeries Value="d => d.Trials" />
<ChartBarSeries Value="d => d.Paid" />
</Chart>
</Card>
{
private record DaySignups(string Day, int Trials, int Paid);
private readonly DaySignups[] _days =
[
new("Mon", 142, 31), new("Tue", 168, 38), new("Wed", 155, 35), new("Thu", 171, 42),
new("Fri", 149, 33), new("Sat", 88, 14), new("Sun", 79, 12),
];
}The chart and its Show data are named from the heading, so the title isn't written twice. For a chart with no heading near it, HideTitle keeps a Title for screen readers only.
To size every chart's own title at once, set --ib-chart-title-size (the theme's --ib-text-lg by default) and --ib-chart-title-weight in your CSS. TitleAlign moves the title to the Center or End.