Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Oxyplot C#日期时间轴在图形中显示点数据_C#_Oxyplot - Fatal编程技术网

Oxyplot C#日期时间轴在图形中显示点数据

Oxyplot C#日期时间轴在图形中显示点数据,c#,oxyplot,C#,Oxyplot,如果我用c#创建一个DateTimeAxis,如下所示: DateTimeAxis xAxis = new DateTimeAxis { Position = AxisPosition.Bottom, StringFormat = "dd/MM/yyyy", Title = "Year", MinorIntervalType = DateTimeIntervalTyp

如果我用c#创建一个DateTimeAxis,如下所示:

        DateTimeAxis xAxis = new DateTimeAxis
        {
            Position = AxisPosition.Bottom,
            StringFormat = "dd/MM/yyyy",

            Title = "Year",
            MinorIntervalType = DateTimeIntervalType.Days,
            IntervalType = DateTimeIntervalType.Days,
            MajorGridlineStyle = LineStyle.Solid,
            MinorGridlineStyle = LineStyle.None,
        };

        FunctionSeries fs = new FunctionSeries();
        fs.Points.Add(new DataPoint(DateTimeAxis.ToDouble(DateTime.Now), 5));
        fs.Points.Add(new DataPoint(DateTimeAxis.ToDouble(new DateTime(1989, 10, 3)), 8));

        PlotModel n = new PlotModel();
        n.Series.Add(fs);
        n.Axes.Add(xAxis);
        n.Axes.Add(new LinearAxis());

        pv.Model = n;
图表上的一切都画得很好,但如果我按下该点,我会得到以下数据作为标签:

年份:0#### X:6.2523


因此,X信息是正确的,但我不知道为什么oxyplot不显示正确的年份?

看起来series
TrackPerformatString
属性存在问题。用于设置单击图形时显示的字符串的格式

有关其定义,请参阅oxyplot文档的第页

它看起来像是将字符串格式字符串
{Date:0.#####}
逐字处理为双精度,而不是用关联属性填充它

要获得正确的输出,请添加
fs.trackperformatstring=“Year:{2:yyyy-MM-dd}X:{4:0.###}”到您的代码。如果希望使用标准的C#DateTime格式字符串语法,可以对日期进行不同的格式设置

,特别有助于了解未记录的设置。特别是以下内容是相关的:

跟踪器格式字符串对于不同的系列有一些变化(应该被记录……也许会改进?),但它至少应该支持以下参数

{0}系列的标题 {1} x轴的标题 {2} x值 {3} y轴的标题 {4} y值


请注意,我是如何使用上面的{2}和{4}分别获得x值和y值的。

您的目标平台是什么(WPF、Xamarin、GTK等)?感谢您的回答,我在原始帖子中添加了我的其余代码。我看不到任何关于你链接的文档的信息可以帮助我,因为“此部分正在构建中”。好的,我现在可以重新创建你的错误。我负责这个案子,谢谢你!如果我添加您的代码行,一切正常!我真的很感谢你的帮助:)祝你愉快weekend@WilliamDenmanTrackPerformatString是否适用于Xamarin表单?