我正在尝试使用 LiveChart 绘制一个简单的 LineSeries。因为计算机/数组索引默认从 0 开始,而人类(非程序员)从 1 开始计数,所以我喜欢显示从 1 开始的值的索引(即 index+1),但不知道如何做到这一点.
我阅读了有关Types and Configurations的 LiveChart 文档,并尝试将索引 + 1 的映射器放入 SeriesCollection,但出现无效参数错误:无法从 'LiveCharts.Configurations.CartesianMapper' 转换为 'LiveCharts.Definitions.Series.ISeriesView '
var mapper1 = new CartesianMapper<double>()
.X((value, index) => index + 1)
.Y((value, index) => value);
sc = new SeriesCollection
{
new LineSeries
{
Values = new ChartValues<double>() {1,2,3,4,1,2,3,4,1,2},
},
mapper1
};