Languages and texts
A chart writes a few texts of its own, in English, Swedish, Norwegian, Danish, Finnish, German, French or Spanish. They are "No data available", "Reset zoom", "Total" in a donut, the download button, and what screen readers hear (the chart description, axis names, keyboard help), and you can change any of them or add your own language.
From the culture
The texts follow the chart's Culture, or the current UI culture when it has none: sv-FI tries
sv-FI, then sv, then falls back to English. Pick a language and zoom the line chart (drag in the
plot), then hover the Reset zoom button for its text. The numbers follow the culture too.
Code
<RioChart Items="revenue" Culture="@(new CultureInfo("sv-SE"))" Zoomable="true" Exportable="true">
<LineSeries Name="Revenue" XValue="r => r.Time" YValue="r => r.Value" Format="#,0 €" />
</RioChart>Changing texts
ChartTexts holds the texts. Change the ones you want with with; the rest stay as they are. Give it to one chart
with Texts:
<RioChart Items="orders" Texts="@(ChartTexts.Swedish with { ResetZoom = "Visa allt", NoData = "Inga ordrar ännu" })">
...
</RioChart>
Or cascade it to every chart in the app. A cascaded value is per user, so it can follow each user's language. A Texts
parameter still wins:
@* MainLayout.razor *@
<CascadingValue Value="_chartTexts">
@Body
</CascadingValue>
@code {
private readonly ChartTexts _chartTexts = ChartTexts.English with { NoData = "Waiting for the first order" };
}Adding a language
Register a language once at startup and every chart with that culture uses it. A registered language takes precedence over a built-in one, so you can also replace the built-in Swedish with your own wording. Texts you leave out fall back to English.
// Program.cs
ChartTexts.Register("pl", new ChartTexts
{
Chart = "Wykres",
NoData = "Brak danych",
ResetZoom = "Resetuj powiększenie",
Total = "Razem",
Summary = "Wykres z {0} serią.|Wykres z {0} seriami.",
});From resx files or IStringLocalizer
If your app already translates with resource files, ChartTexts.From reads the texts by key. The keys are the property names
in the table below (also in ChartTexts.Keys). Keys your resources don't have keep the fallback text, here the built-in
language, so you only translate what you want to change.
Give the localizer a class of your own: IStringLocalizer<ChartTexts> would look for the resources in the RioCharts
assembly, not yours. Any IStringLocalizer works the same way, also one that reads from a database.
// Program.cs (package Microsoft.Extensions.Localization)
builder.Services.AddLocalization(o => o.ResourcesPath = "Resources");
// ChartResources.cs: a marker class; its texts are Resources/ChartResources.resx, ChartResources.sv.resx, ...
// with keys such as NoData and ResetZoom.
public sealed class ChartResources;@* MainLayout.razor *@
@inject IStringLocalizer<ChartResources> L
<CascadingValue Value="_chartTexts">
@Body
</CascadingValue>
@code {
private ChartTexts _chartTexts = ChartTexts.English;
protected override void OnInitialized() =>
_chartTexts = ChartTexts.From(key => L[key] is { ResourceNotFound: false } s ? s.Value : null,
fallback: ChartTexts.For(CultureInfo.CurrentUICulture));
}
Skia export takes texts too: ExportOptions.Texts (default:
from Culture).
Templates
Some texts are templates: {0}, {1}… are filled in. A text with a count can have two forms separated by
|: the first is used when the count is 1, so "{0}: {1} value|{0}: {1} values" reads "Web: 1 value" or "Web:
48 values". A template that cannot be filled in (a stray brace) falls back to English instead of breaking the chart.
All texts
| Key | English | Svenska |
|---|---|---|
Chart | Chart | Diagram |
NoData | No data available | Inga data |
ChartFailed | The chart could not be drawn | Diagrammet kunde inte ritas |
AllSeriesHidden | All series are hidden | Alla serier är dolda |
AllSlicesHidden | All slices are hidden | Alla delar är dolda |
Other | Other | Övrigt |
Total | Total | Totalt |
Size | Size | Storlek |
ResetZoom | Reset zoom | Återställ zoom |
Download | Download | Ladda ner |
DownloadFormat | Download {0} | Ladda ner {0} |
DownloadChart | Download chart | Ladda ner diagram |
ChartRole | chart | diagram |
Legend | Legend | Teckenförklaring |
XAxis | X axis | X-axel |
YAxis | Y axis | Y-axel |
AxisRange | {0}, from {1} to {2} | {0}, från {1} till {2} |
SeriesPoints | {0}: {1} data point|{0}: {1} data points | {0}: {1} datapunkt|{0}: {1} datapunkter |
Summary | Chart with {0} series. | Diagram med {0} serie.|Diagram med {0} serier. |
SummaryTitled | Chart "{1}" with {0} series. | Diagram "{1}" med {0} serie.|Diagram "{1}" med {0} serier. |
SeriesValues | {0}: {1} value|{0}: {1} values | {0}: {1} värde|{0}: {1} värden |
LowestHighest | lowest {0} at {1}, highest {2} at {3} | lägst {0} vid {1}, högst {2} vid {3} |
Trend | trend {0} | {0} trend |
Rising | rising | stigande |
Falling | falling | fallande |
Stable | stable | stabil |
ValueRange | {0} to {1} | {0} till {1} |
LastValue | last {0} | senast {0} |
HistogramPeak | {0}: {1} value, most from {2} to {3}|{0}: {1} values, most from {2} to {3} | {0}: {1} värde, flest från {2} till {3}|{0}: {1} värden, flest från {2} till {3} |
RangeBarSummary | {0}: {1} bar in {4} rows, from {2} to {3}|{0}: {1} bars in {4} rows, from {2} to {3} | {0}: {1} stapel i {4} rader, från {2} till {3}|{0}: {1} staplar i {4} rader, från {2} till {3} |
DurationUnits | d h min s | d h min s |
NoDataShort | No data. | Inga data. |
BoxMax | Max | Max |
BoxUpperQuartile | Upper quartile | Övre kvartil |
BoxMedian | Median | Median |
BoxLowerQuartile | Lower quartile | Nedre kvartil |
BoxMin | Min | Min |
BoxCount | Count | Antal |
BoxOutliers | Outliers | Avvikande värden |
CandleOpen | Open | Öppning |
CandleHigh | High | Högsta |
CandleLow | Low | Lägsta |
CandleClose | Close | Stängning |
CandleChange | Change | Förändring |
PieChart | Pie chart | Cirkeldiagram |
DonutChart | Donut chart | Ringdiagram |
RadialBarChart | Radial bar chart | Radiellt stapeldiagram |
GaugeChart | Gauge | Mätare |
BulletChart | Bullet chart | Bulletdiagram |
FunnelChart | Funnel chart | Trattdiagram |
FunnelOfFirst | Of first stage | Av första steget |
FunnelOfPrevious | Of previous stage | Av föregående steg |
CalendarChart | Calendar heatmap | Kalenderdiagram |
CalendarDays | {0} with {1} day: {2}|{0} with {1} days: {2} | {0} med {1} dag: {2}|{0} med {1} dagar: {2} |
Target | Target | Mål |
RadarChart | Radar chart | Radardiagram |
Treemap | Treemap | Trädkarta |
ShareOfGroup | Share of group | Andel av gruppen |
ShareOfTotal | Share of total | Andel av totalen |
TreemapAll | All | Alla |
TreemapShow | Show {0} | Visa {0} |
TreemapPathLabel | Path | Sökväg |
Map | Map | Karta |
MapWorld | World | Världen |
TreemapLeftOut | {0} item with zero or negative value left out|{0} items with zero or negative values left out | {0} post med noll eller negativt värde utelämnad|{0} poster med noll eller negativa värden utelämnade |
PolarItems | {0} with {1} item: {2}|{0} with {1} items: {2} | {0} med {1} post: {2}|{0} med {1} poster: {2} |
PolarNoData | {0}, no data. | {0}, inga data. |
LegendHidden | {0}, hidden | {0}, dold |
LegendNoData | {0}, no data | {0}, inga data |
More | and {0} more | och {0} till |
KeysPoints | Use Left and Right to move between points. | Använd vänster- och högerpil för att flytta mellan punkter. |
KeysPointsAndSeries | Use Left and Right to move between points, Up and Down to change series. | Använd vänster- och högerpil för att flytta mellan punkter, upp- och nedpil för att byta serie. |
KeysSlices | Use the arrow keys to move between slices. | Använd piltangenterna för att flytta mellan delarna. |
KeysZoom | Plus and minus zoom, Shift with Left and Right pans, 0 shows all data. | Plus och minus zoomar, Skift med vänster- och högerpil panorerar, 0 visar all data. |
KeysSelect | Press Enter to select a point, Escape to leave. | Tryck Enter för att välja en punkt, Escape för att lämna. |
KeysLeave | Press Escape to leave. | Tryck Escape för att lämna. |
Position | {0} of {1} | {0} av {1} |