Pre loader

Align DatePickers with the XAxis

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

Answered
1
0

Hello,

I have a SciChart with as XAxis a DateTimeAxis and a dynamic/changing number of YAxes. Under the chart I have two DatePickers, the left one linked to the start of the DateTimeAxis, the right one linked to the end of the DateTimeAxis.

Now I would like to horizontally align these DatePickers right under the XAxis (so not just under SciChartSurface, see attached screenshot). How do I do this ? Note that the number of YAxes change, so I cannot just hardcode a margin.

Thanks in advance for any help,
Stefaan

Images
  • You must to post comments
Best Answer
1
0

Hi Alex

Clamping Axis.Visiblerange in SciChart WPF can be achieved with a VisibleRangeChanged event handler

Take a look at Clipping the Axis.VisibleRange on Zoom and Pan

Clipping Axis.VisibleRange in Code To clip the VisibleRange and force a certain maximum or minimum, just use the following code:

axis.VisibleRangeChanged += (s, e) =>
  {
     // e is VisibleRangeChangedEventArgs
     // Assuming axis is NumericAxis
  
     if (e.NewVisibleRange != null && e.NewVisibleRange.Min < 0)
     {
        // Force minimum visiblerange to zero always
        ((NumericAxis)sender).VisibleRange = new DoubleRange(0, e.NewVisibleRange.Max);
     }
  };
  

There are other methods in there such as using VisibleRangeLimit but these have their limitations (no pun intended), such as not clamping when user zoom/pan occurs

  • srillaert
    Thanks Andrew, this helped ! The critical part of my code for this is now : DependencyPropertyDescriptor.FromProperty(FrameworkElement.ActualWidthProperty, typeof(FrameworkElement)).AddValueChanged(sciChartSurface.AxisAreaLeft, RecalculatePeriodSelectorMargin); Enjoy the evening, Stefaan
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.