OXYPLOT:如何在TrackErformatstring中计算?

发布于 2025-01-27 05:44:08 字数 244 浏览 1 评论 0原文

我尝试创建一个线段系列,其中不仅应在跟踪器中显示x-和y值,而且还应显示一个属性:

var series = new LineSeries {TrackerFormatString = "X:{2}\nY:{4}\nZ:{2*(1-4)}"};
series.Points.AddRange(...);

我希望另一个属性z =(1-y) * x是显示在跟踪器的第三行中。怎么可能?

I try to create a line series where not only x- and y-values shall be displayed in the tracker, but one more property:

var series = new LineSeries {TrackerFormatString = "X:{2}\nY:{4}\nZ:{2*(1-4)}"};
series.Points.AddRange(...);

I want another property Z = (1-Y) * X to be displayed in the third row of the tracker. How is this possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倒带 2025-02-03 05:44:08

可以通过创建自定义

public class CustomDataPoint : IDataPointProvider
{
        public double X { get; }
        public double Y { get; }
        public double Z{ get; }

        public CustomDataPoint(double x, double y)
        {
            X = x;
            Y = y;
            Z = (1 - Y) * X;
        }

        public DataPoint GetDataPoint()
        {
            return new DataPoint(X, Y);
        }
}

,然后将其添加到系列中:

var series = new LineSeries {TrackerFormatString = "X:{2}\nY:{4}\nZ:{Z}"};
series.ItemsSource = new [] {
    new CustomDataPoint(...),
    new CustomDataPoint(...)
};

请注意,您需要使用itemssource属性。您不能简单地使用series.point.Addrange(...)添加点。

It is possible by creating a custom

public class CustomDataPoint : IDataPointProvider
{
        public double X { get; }
        public double Y { get; }
        public double Z{ get; }

        public CustomDataPoint(double x, double y)
        {
            X = x;
            Y = y;
            Z = (1 - Y) * X;
        }

        public DataPoint GetDataPoint()
        {
            return new DataPoint(X, Y);
        }
}

And then add it to the series:

var series = new LineSeries {TrackerFormatString = "X:{2}\nY:{4}\nZ:{Z}"};
series.ItemsSource = new [] {
    new CustomDataPoint(...),
    new CustomDataPoint(...)
};

Note that you need to use the ItemsSource property. You cannot simply add points with series.Point.AddRange(...).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文