c# - 如何在 LineSeries 图上显示文本?

标签 c# oxyplot

我正在尝试将一个点的值打印到绘图上,但提供的文档不完整或令人困惑。我知道 TrackerFormatString 值可以做类似的事情,但我希望文本始终位于随不同值动态变化的图上。有什么我可能忽略了或者我可以研究的吗?

var series1 = new LineSeries { Title = "Stage I", MarkerType = MarkerType.Circle, Smooth = true, TrackerFormatString = "Stage I\nYear: {2:0.0}\n{4:0.0} %" };
//let's say I have a line series like this
//I need to enter some sort of text on the plot that has the values of the below points:
        series1.Points.Add(new DataPoint(0.0, 100.0));
        series1.Points.Add(new DataPoint(1, 82.3));
        series1.Points.Add(new DataPoint(3, 59.2)); 
        series1.Points.Add(new DataPoint(5, 47.7));

This is what I have:

This is what I need:

如能提供任何形式的帮助,我们将不胜感激!

最佳答案

您可以为绘图添加注释。要显示文本,请使用 TextAnnotation

将注释添加到您的模型,为位置提供 DataPoint 并为要显示的文本提供 Text。例如

yourModel.Annotations.Add(new TextAnnotation { TextPosition = new DataPoint(DateTimeAxis.ToDouble(now), wert), Text = "82.3%" });

关于c# - 如何在 LineSeries 图上显示文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44419265/

相关文章:

c# - .NET Process.Start 默认目录?

c# - 在 C# 中使用时间跨度简化 if else 条件

c# - 无法识别工具版本 "15.0"- Visual Studio 2019 (v16.0.0 Preview 5.0) 中的项目不兼容/已卸载

c# - 绑定(bind) OxyPlot Tracker 并在 TextBlock 中设置获取值

c# - 在 C# 中捕获 COM 异常的最佳实践是什么?

c# - 如何解决另一个进程正在使用的文件?

c# - PlotView 和 Plot 之间有什么不同?

charts - 如何在 xamarin.android 中使用 oxyplot 创建圆环图?

c# - 如何防止氧图在一个轴上缩放?

c# - 如何从 Oxplot 图中删除轴但保留缩放和平移功能?