Basic Area
This sample uses the CommunityToolkit.Mvvm package
and C# 14 partial properties: C# 14 is the default with the .NET 10 SDK, on older target frameworks set
<LangVersion>14</LangVersion>. You can learn more about the samples
here.
View model
namespace ViewModelsSamples.Lines.Area;
public class ViewModel
{
public double[] Values { get; set; } =
[-2, -1, 3, 5, 3, 4, 6];
}
XAML
<UserControl
x:Class="AvaloniaSample.Lines.Area.View"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:lvc="using:LiveChartsCore.SkiaSharpView.Avalonia"
xmlns:vms="using:ViewModelsSamples.Lines.Area"
x:DataType="vms:ViewModel">
<UserControl.DataContext>
<vms:ViewModel/>
</UserControl.DataContext>
<lvc:CartesianChart
DrawMarginFrame="{lvc:Frame
Stroke={lvc:SolidColorPaint Color='#64b4b4b4'},
Fill={lvc:SolidColorPaint Color='#32dcdcdc'}}">
<lvc:CartesianChart.Series>
<lvc:XamlLineSeries
Values="{Binding Values}"
Fill="{lvc:SolidColorPaint Color='#6495ED'}"
Stroke="{x:Null}"
GeometryFill="{x:Null}"
GeometryStroke="{x:Null}"/>
</lvc:CartesianChart.Series>
</lvc:CartesianChart>
</UserControl>
Related articles:
~/samples/lines/area/template.md