Line Chart
A line per series across the categories, smooth or straight.
A line per series, from one edge of the plot to the other. See Charts for how data, colours and updates work in every chart.
Installation
bash
shellui-native add line-chart
Platforms: MAUI · Avalonia. Also installs chart, the core every chart shares. The chart colours are theme tokens added with the charts, so in a project whose shell came from an older CLI, run shellui-native update shell first.
Usage
Basic
Lines are smooth by default: the curve passes through every point without overshooting it.
<ui:LineChart Labels="Mon, Tue, Wed, Thu, Fri, Sat, Sun" Description="Docs visitors this week" HeightRequest="260">
<ui:ChartSeries Name="shellui.dev" Values="1200, 1900, 1500, 2100, 1800, 900, 750" />
<ui:ChartSeries Name="native.shellui.dev" Values="400, 650, 700, 980, 1100, 620, 480" />
</ui:LineChart><ui:LineChart Labels="Mon, Tue, Wed, Thu, Fri, Sat, Sun" Description="Docs visitors this week" Height="260">
<ui:ChartSeries Name="shellui.dev" Values="1200, 1900, 1500, 2100, 1800, 900, 750" />
<ui:ChartSeries Name="native.shellui.dev" Values="400, 650, 700, 980, 1100, 620, 480" />
</ui:LineChart>Not available on yet
Straight lines and dots
IsSmooth="False" joins the points with straight segments, and ShowDots marks each one.
<ui:LineChart Labels="May, Jun, Jul, Aug, Sep, Oct" IsSmooth="False" ShowDots="True" ShowLegend="False" HeightRequest="260">
<ui:ChartSeries Name="Stars" Values="12, 30, 48, 75, 110, 164" />
</ui:LineChart><ui:LineChart Labels="May, Jun, Jul, Aug, Sep, Oct" IsSmooth="False" ShowDots="True" ShowLegend="False" Height="260">
<ui:ChartSeries Name="Stars" Values="12, 30, 48, 75, 110, 164" />
</ui:LineChart>Not available on yet
MAUI and Avalonia
- MAUI draws the chart in a
GraphicsView; give it aHeightRequest. On touch screens a tap or a drag shows the tooltip. - Avalonia draws it in
Render, in the control's own font; give it aHeight.ChartSeries.Coloris an AvaloniaColor(Color.Parse("#E76E50")).
API
LineChart
XAML children go to Series.
| Property | Type | Default | Description |
|---|---|---|---|
IsSmooth |
bool |
true |
Curves the line through its points; false joins them with straight segments. |
ShowDots |
bool |
false |
A dot on every point. |
StrokeWidth |
double |
2 |
Width of each line. |
ShowGrid |
bool |
true |
Grid lines behind the plot, at each value axis step. |
ShowXAxis |
bool |
true |
The labels under the plot. |
ShowYAxis |
bool |
true |
The labels beside the plot. |
Minimum |
double |
Fits the data | The ends of the value axis; by default they fit the data and include zero. |
Maximum |
double |
Fits the data | The other end of the value axis; see Minimum. |
Labels |
ChartLabels (MAUI) · ChartLabels? (Avalonia) |
null |
The category names along the axis, or the slice names of a pie. |
ShowLegend |
bool |
true |
Shows the series (or slice) names with their colours under the chart. |
ShowTooltip |
bool |
true |
Shows the values under the pointer (or the finger). |
IsAnimated |
bool |
true |
Grows the chart in when it first appears. |
ValueFormat |
string |
"#,0.##" |
A .NET number format for axis and tooltip values. |
EmptyText |
string |
"No data" |
Shown when there are no values. |
Description |
string |
— | What the chart shows, for screen readers. |
| Method | Description |
|---|---|
Refresh() |
Redraws the chart. Call it after changing the numbers inside a series' Values. |
PlayAnimation() |
Grows the chart in again. |
ChartSeries
| Property | Type | Default | Description |
|---|---|---|---|
Name |
string |
— | Shown in the legend and the tooltip. |
Values |
ChartValues |
Empty | The numbers, one per category. In XAML, a comma-separated list. |
Color |
Color? |
null |
Replaces the theme's chart color for this series. |