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

0 votes
0 answers


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.

0 votes

Hi there,
I’m trying to catch a VisibleRangeChanged Event of a DateTimeAxisViewModel, but it is never called.
Strangely, it work’s with a numeric axis viewModel?!
I’m refering to the AxisBinding and Annotation Binding Example in the Examples Suite.
I added a MouseWheelZoomModifier to be able to change the VisibleRange


In the InitializeAxes method in SciChartMvvmBindingsViewModel two lines were added to catch the VisibleRangeChanged Event:

            var xNumAxis = new NumericAxisViewModel
                AxisAlignment = AxisAlignment.Bottom,
                AxisTitle = "XAxis",
                DrawMajorBands = false,
                TextFormatting = "0.00#",
                VisibleRange = new DoubleRange(0, 10),
                BorderThickness = new Thickness(3),
                BorderBrush = new SolidColorBrush(Colors.CadetBlue)
            xNumAxis.VisibleRangeChanged += xNumAxis_VisibleRangeChanged; //catch num axis event

            var xDateTimeAxis = new DateTimeAxisViewModel
                AxisAlignment = AxisAlignment.Top,
                Id = "DateTimeAxis",
                VisibleRange = new DateRange(new DateTime(2017, 1, 1), new DateTime(2017, 1, 31)),
                StyleKey = "DateTimeAxisStyle"
            xDateTimeAxis.VisibleRangeChanged += xDateTime_VisibleRangeChanged; //catch date time axis event


Now, when I change the zoom level I jump into the xNumAxis_VisibleRangeChanged-method, but never in the xDateTime_VisibleRangeChanged-method.

  • Tim asked 5 years ago
  • last active 2 years ago
Showing 2 results
This template supports the sidebar's widgets. Add one or use Full Width layout.