gpt4 book ai didi

c# - 在 Oxyplot 的线系列数据点中添加字符串值

转载 作者:太空宇宙 更新时间:2023-11-03 19:57:13 25 4
gpt4 key购买 nike

谁能告诉我如何在 Oxyplot 的线系列数据点中添加字符串值?

我有一个列表,它是字符串的键值对,double 并且想将它添加到数据点。

例子:字符串值为 10-15,15-20, ...

double 值是 10、20、30、...

我希望我的 x 轴刻度点显示为例如(10-15、15-20 等)

代码如下:

foreach (var points in list)
{
lineseriesobject.Points.Add(new OxyPlot.DataPoint(Convert.ToDouble(points.Key), Convert.ToDouble(points.Value)));
}

最佳答案

只需使用PointAnnotation!

foreach (var points in list)
{
var pointAnnotation = new PointAnnotation()
{
X = Convert.ToDouble(points.Key),
Y = Convert.ToDouble(points.Value),
Text = String.Format("{0}-{1}",points.Key,points.Value)
});
lineSeriesObject.Points.Add(new OxyPlot.DataPoint(Convert.ToDouble(points.Key), Convert.ToDouble(points.Value)));
plotModelObject.Annotations.Add(pointAnnotation);
}
plotModelObject.Series.Add(lineSeriesObject);

看看OxyPlot Example Browser注释下。

关于c# - 在 Oxyplot 的线系列数据点中添加字符串值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32269785/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com