How do I enter a 'null' value in a LineSeries?

时间:2017-01-15 12:27:33

标签: livecharts

I have a 'line' of values where some information might be missing.

e.g.:

Jan - 10, Feb - 20, Mar - 15, Apr - null, Jun - 45 ... etc

I would expect that in the chart the NULL value will simply appear 'empty' (missing) from the line.

e.g.

enter image description here

内放置图像中的文本(纵向和横向)

我尝试过使用ChartValues<decimal?>,但图表在XAML中抱怨它does not know how to plot Nullable 1`。

帮助?

1 个答案:

答案 0 :(得分:3)

LiveCharts使用double.NaN代替null这是网站上的示例:

https://lvcharts.net/App/examples/v1/wpf/Missing%20Points

Series = new SeriesCollection
        {
            new LineSeries
            {
                Values = new ChartValues<double>
                {
                    4,
                    5,
                    7,
                    8,
                    double.NaN,
                    5,
                    2,
                    8,
                    double.NaN,
                    6,
                    2
                }
            }
        };

XAML

<lvc:CartesianChart Series="{Binding Series}"></lvc:CartesianChart>