DateTimeAxis with IntervalType == DateTimeIntervalType.Minutes

Oystein Bjorke fa 10 anys 0
This discussion was imported from CodePlex

swiszcz wrote at 2013-05-06 10:33:

Hi,

I want to display measurement data, where measurements were made every full minute (60 seconds), so I'm using DateTimeAxis with IntervalType == DateTimeIntervalType.Minutes on X axis. I'm using DateTimeAxis.ToDouble() to calculate x-coordinate and I obtain correct point series.

However, I was expecting ticks on the X axis to appear every full minute, but the actual distance between ticks is one minute +- a few seconds (see Example screen capture.).

Is there a way to have tick's distance equal to exactly 1 minute?

Regards,
Maciek
    public static PlotModel DateTimeAxisExample()
    {
        var plotModel1 = new PlotModel();
        var linearAxis1 = new LinearAxis();
        linearAxis1.MinorGridlineStyle = LineStyle.Dot;
        plotModel1.Axes.Add(linearAxis1);

    var dateTimeAxis1 = new DateTimeAxis();
        dateTimeAxis1.IntervalType = DateTimeIntervalType.Minutes;
        dateTimeAxis1.EndPosition = 0;
        dateTimeAxis1.StartPosition = 1;
        dateTimeAxis1.StringFormat = "hh:mm:ss";
        plotModel1.Axes.Add(dateTimeAxis1);

        return plotModel1;
    }

objo wrote at 2013-05-06 11:10:

I think there is a bug in the DateTimeAxis. Maybe this is related to double precision accuracy. I am adding a new issue:
https://oxyplot.codeplex.com/workitem/10045

swiszcz wrote at 2013-05-07 14:58:

Hi,

I've found that, in this case, in class: OxyPlot.Axes.Axis, in method: protected static IList<double> CreateTickValues(double min, double max, double step). commenting line: x = x.RemoveNoise(); solves a problem.

Good code, and a good library, by the way.
Thanks!

objo wrote at 2013-06-08 11:57:

Thanks for the solution, I will keep this in mind when looking into the DateTimeAxis again! I think I need to add more tests before I remove the 'RemoveNoise' line.

raphay wrote at 2013-07-04 15:31:

Hi,
I have another similar problem, sometimes at the minute or seconde scale, some major ticks doesn't appears

Image

I use Nugget, so i wonder if the solution proposed by swiszcz is available in the lastest version.

Thank you for your answer, your work is awesome,

Regards

swiszcz wrote at 2013-07-04 15:45:

Hi Raphay,

Although commenting line: x = x.RemoveNoise(); solves a my problem, i have no idea how does it influence the rest of a code (and it may as it is in a base class). So I just made a private fork of OxyPlot.

Best regards