SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & Android Chart Components

0
0

Hello,

i have a custom DateTimeAxisViewModel and want to set major and minor ticks by user input. If the user sets valid values i use following code:

AutoTicks = false;
MajorDelta = TimeSpan.FromSeconds(USERINPUT);
MinorDelta = TimeSpan.FromSeconds(USERINPUT);

Everything works fine. If the user sets an invalid input i want to automatically calculate major and/or minor ticks. My idea was to use the DateTimeTickProvider and call GetMajorTicks()/GetMinorTicks() and then use the result to set the delta like in the code example above.
However GetMajorTicks()/GetMinorTicks() need IAxisParams as input. I couldn’t find IAxisParams as a member of my DateTimeAxisViewModel so i tried this:

public class CustomAxisParams : IAxisParams
{
    public IRange GetMaximumRange()
    {
        throw new NotImplementedException();
    }

    public IRange VisibleRange { get; set; }
    public IRange<double> GrowBy { get; set; }
    public IComparable MinorDelta { get; set; }
    public IComparable MajorDelta { get; set; }

    public AxisParams(IRange visibleRange, IRange<double> growBy, IComparable minorDelta, IComparable majorDelta)
    {
        VisibleRange = visibleRange;
        GrowBy = growBy;
        MinorDelta = minorDelta;
        MajorDelta = majorDelta;
    }
}

public class CustomDateTimeAxisViewModel : DateTimeAxisViewModel
{
    private TimeSpan GetAutoMajorDelta()
    {
        var dateTimeTickProvider = new DateTimeTickProvider();
        var axisParams = new AxisParams(VisibleRange, GrowBy, MinorDelta, MajorDelta);
        var majorTicks = dateTimeTickProvider.GetMajorTicks(axisParams);

        if (majorTicks.Count < 2)
        {
            return TimeSpan.Zero;
        }

        // return diff between majorTicks[0] and majorTicks[1]
    }
}

This does not work because GetMajorTicks() returns always an empty list. How can i achieve the desired behaviour?

Thanks for your help.
Alexander

Version
5.3.0.11954
  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.

SciChart WPF v6 BETA released! Note pricing/licensing changes are coming. Contact us to beat the rise!Read more
+