1

我需要在窗口中以“HH:mm:ss”格式显示时间。

            Plot = new PlotModel();
            Plot.TextColor = OxyColors.Black;

            Plot.Axes.Add(new LinearAxis(AxisPosition.Left, 0, 100));
            Plot.Axes.Add(new DateTimeAxis(AxisPosition.Bottom)
            {
                //StringFormat = "h:mm",
                IsZoomEnabled = false,
                IntervalType = DateTimeIntervalType.Seconds,
                IntervalLength = 80
            });

但它不起作用。

我想在 DateTimeAxis: 0:00:01 - 0:00:05 - 0:00:10 等中看到这个结果。请帮帮我。

在此处输入图像描述

https://github.com/oxyplot

    private double _xAxisCounter;

    private void UpdateChart(int mixerNumber)
    {
        DetailsPlot details = _mixerDetailsPlots[mixerNumber];
        UpdateChart(details.LineOfCurrent, details.Mixer.Current.Value);
        UpdateChart(details.LineOfMaximumCurrent, details.Mixer.MaximumCurrent);
    }

    private void UpdateChart(LineSeries line, double value)
    {
        if (line.Points.Count > 500)
        {
            line.Points.RemoveAt(0);
        }
        line.Points.Add(new DataPoint(_xAxisCounter, value));
    }
4

1 回答 1

3

我很确定你在追求这样的事情:

var BottomAxis = new DateTimeAxis();
BottomAxis.MajorGridlineStyle = LineStyle.Solid;
BottomAxis.MinorGridlineStyle = LineStyle.Dot;
BottomAxis.LabelFormatter = d => { return DateTimeAxis.ToDateTime(d).ToString("HH:mm:ss\nyy/MM/dd"); };
myPlotModel.Axes.Add(BottomAxis);

我所做的只是将格式添加到 DateTime 轴。在您的情况下,您不需要格式的日期部分。

希望这可以帮助!

于 2015-04-30T10:11:27.977 回答