WPF编程,Live Charts使用说明(35)——不连续曲线(间断线)

在这里插入图片描述

当您不知道直线系列中的值时,请 使用double.NaN,该点将是不确定的,绘制直线系列时将被忽略。

后台:

using System.Windows.Controls;
using LiveCharts;
using LiveCharts.Wpf;
 
namespace Wpf.CartesianChart.Missing_Line_Points
{
    public partial class MissingPointsExample : UserControl
    {
        public MissingPointsExample()
        {
            InitializeComponent();
 
            Series = new SeriesCollection
            {
                new LineSeries
                {
                    Values = new ChartValues<double>
                    {
                        4,
                        5,
                        7,
                        8,
                        double.NaN,
                        5,
                        2,
                        8,
                        double.NaN,
                        6,
                        2
                    }
                }
            };
 
            DataContext = this;
        }
 
        public SeriesCollection Series { get; set; }
 
    }
}

前台:

<UserControl x:Class="Wpf.CartesianChart.Missing_Line_Points.MissingPointsExample"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <lvc:CartesianChart Series="{Binding Series}">
        </lvc:CartesianChart> 
    </Grid>
</UserControl>

猜你喜欢

转载自blog.csdn.net/qq_43307934/article/details/105645929