【问题标题】:.NET WPF. OxyPlot TimeFormat.NET WPF。 OxyPlot 时间格式
【发布时间】:2014-09-03 06:07:30
【问题描述】:

我需要在窗口中以“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));
    }

【问题讨论】:

    标签: string-formatting time-format oxyplot


    【解决方案1】:

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

    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 轴。 在您的情况下,您不需要格式的日期部分。

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-23
      • 2017-08-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多