Line Smoothness
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.Straight;
public class ViewModel
{
public double[] Values1 { get; set; } =
[5, 0, 5, 0, 5, 0];
public double[] Values2 { get; set; } =
[7, 2, 7, 2, 7, 2];
}
XAML
<UserControl
x:Class="AvaloniaSample.Lines.Straight.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.Straight"
x:DataType="vms:ViewModel">
<UserControl.DataContext>
<vms:ViewModel/>
</UserControl.DataContext>
<!--
The line smoothness property controls the curve between points
it goes from 0 to 1, where 0 is straight and 1 is the most curved.
-->
<lvc:CartesianChart>
<lvc:CartesianChart.Series>
<lvc:XamlLineSeries
Values="{Binding Values1}"
Fill="{x:Null}"
GeometrySize="0"
LineSmoothness="0"/>
<lvc:XamlLineSeries
Values="{Binding Values2}"
Fill="{x:Null}"
GeometrySize="0"
LineSmoothness="1"/>
</lvc:CartesianChart.Series>
</lvc:CartesianChart>
</UserControl>
Related articles:
~/samples/lines/straight/template.md