【发布时间】:2018-06-16 22:26:31
【问题描述】:
我是 WPF 新手,我正在从事的项目要求我在 XY 图表上绘制一个双精度列表。我将 Oxyplot 添加到我的图表项目中,但我在获取绘图方面遇到了挑战。
我遵循了 Oxyplot 网站上的示例(参见下面的代码),但我发现 DataPoint 只能接受 x 和 y 的双精度值,而不是数组或双精度列表。
如何为 XValues 绘制 List<double> 为 YValues 绘制 List<double>?
namespace WpfApplication2
{
using System.Collections.Generic;
using OxyPlot;
public class MainViewModel
{
public MainViewModel()
{
this.Title = "Example 2";
this.Points = new List<DataPoint>
{
new DataPoint(0, 4),
new DataPoint(10, 13),
new DataPoint(20, 15),
new DataPoint(30, 16),
new DataPoint(40, 12),
new DataPoint(50, 12)
};
}
public string Title { get; private set; }
public IList<DataPoint> Points { get; private set; }
}
}
【问题讨论】:
-
已编辑:请问如何将 XValues 列表和 YValues 列表传入 DataPoint,它一次只接受 x 和 y 的单个值?
-
您需要将两个双精度列表投影/合并到一个对象列表中(例如
DataPoint)。