OxyPlot中DateTimeAxis

版权声明:版权所有,需要请联系作者 https://blog.csdn.net/weixin_42930928/article/details/81984549

DateTimeAxis是用来在坐标轴上展示日期/时间值的。

如果添加一个DataPoint 值到Series中,DateTime值需要使用如下方法进行转化

mySeries.Points.Add(new DataPoint(DateTimeAxis.ToDouble(myDateTime),myValue))

对DateTimeAxis需要使用StringFormat属性进行转化

Code Description Example
yyyy year “2011”
yy year “11”
MM month “01”
MMM month “Jan”
MMMM month “January”
w week number “4”
ww week number “04”
dd day “26”
hh hour “04”
HH hour “16”
mm minute “37”
ss seconds “23”
yyyy-MM-dd   “2011-01-26”
MM/dd/yyyy   “01/26/2011”

 例子

var model = new PlotModel { Title = "DateTimeAxis" };

var startDate = DateTime.Now.AddDays(-10);
var endDate = DateTime.Now;

var minValue = DateTimeAxis.ToDouble(startDate);
var maxValue = DateTimeAxis.ToDouble(endDate);

model.Axes.Add(new DateTimeAxis { Position = AxisPosition.Bottom, Minimum = minValue, Maximum = maxValue, StringFormat = "M/d"});

猜你喜欢

转载自blog.csdn.net/weixin_42930928/article/details/81984549
今日推荐