DateTimeAxis minimum value incorrect?

Apr 19, 2011 at 7:26 AM

I'm open SilverlightDemo project and modify filling:

            var tmp = new PlotModel("Test");
            tmp.Axes.Add(new LinearAxis(AxisPosition.Left) { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, TickStyle = TickStyle.Outside});
            DateTime dt = new DateTime(201011);
            tmp.Axes.Add(new DateTimeAxis(dt, dt.AddDays(1), AxisPosition.Bottom, nullnullDateTimeIntervalType.Hours)
                             {
                                 MajorGridlineStyle = LineStyle.Solid,
                                 Angle = 90,
                                 StringFormat = "HH:mm",
                                 MajorStep = 0.041666/2// 1/24 = 1 hour, 1/24/2 = 30 minutes
                                 IsZoomEnabled = true,
                                 MaximumPadding = 0,
                                 MinimumPadding = 0,
                                 TickStyle = TickStyle.None
                             });
            
            var ls = new LineSeries("Line1") {DataFieldX = "X", DataFieldY = "Y" };
            List<Item> ii = new List<Item>();
            
            for (int i = 0; i < 24; i++)
                ii.Add(new Item() {X = dt.AddHours(i), Y = i*i});
            ls.ItemsSource = ii;
            tmp.Series.Add(ls);
            tmp.PlotMargins = new OxyThickness(400040);          
            plot1.Model = tmp;

As you see, series contain 24 points, one point per each hour:

But, how I can set minimum value to 00:00 and points 00:30, 01:00, 01:30 and so on?

I playing with some Minimum / ActualMinimum and other properties of DateTimeAxis axis, but I can't found solution for my task.

Coordinator
Apr 19, 2011 at 9:58 AM

hi Denisio, your 'step' size is inaccurate - replace with "MajorStep = 1.0/24/2" and it should work.

I see the AxisBase.CreateTickValues might need some improvements to handle floating point precision issues better.

Also note that the DateTimeAxis and TimeSpanAxis are not quite finished yet, I will do some refactoring soon.

Apr 19, 2011 at 10:11 AM

Excellent! Thank you very much!