Pre loader

Axis range

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

1
0

Hi,

I feel this should be obvious but I cannot find the answer in the docs. I have multiple Y axis and I want all of them to start at 0 and autoRange only the max value. Also, the zooming should not be affected, it should have normal behavior. I just want the axis to go from 0 to auto max value when we call ZoomExtents(). The default behavior of the ZoomExtents() is auto min value to auto max value.

Is there any way we can achieve this with SciChart?

Thank you,
Alex

Version
8.3.0.28019
  • Alexandru Neamtu
    I have tried to use the GrowBy method setting the min for every Y axis to something huge like 1e100 and the max to 0.1 (10%). Then by using the VisibleRangeLimit I have limited the visible range to (0, max value computed by GetMaximumRange().Max). This works but we lose the padding of 10%, which is normal because 10% is computed from “max of serie” – “min of serie”. Is there any other strategy that lets us keep the 10% margin above the max value?
  • You must to post comments
0
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

  • You must to post comments
0
0

Hi Andrew,

Thank you for your answer!

In our case, we do not want to clip the visible range. What I am trying to achieve is the following: I have a series with some number of data points. Let us assume that in this series the lowest value is 67 and the highest value is 71. If we plot this normally with autorange = once, it will auto-range the Y axis to the visible range (67, 71). What I would like is to use the autorange feature so it automatically calculates the maximum range of Y axis but I would like to minimum range for Y axis to be 0 not 67 when we use ZoomExtentsModifier. The rest of the behaviors I do not want to affect: zooming, panning, dragging. What I am trying to say is that when I play with the zoom I do not want to restrict it. For example, if I play with the zoom I would like the range to modify to let’s say (68, 70) but also (-20, 100) (no clipping). But when we double-click the chart to trigger the ZoomExtentsModifier I would like to visible range to go to (0, 71) instead of (67, 71).

I am in an MVVM environment.
As I said in my comment I got it working the way I want by taking advantage of the GrowBy property. What I did was:

DoubleRange dr = axis.GetMaximumRange().AsDoubleRange();
axis.GrowBy = new DoubleRange(dr.Min / dr.Diff, dr.Max * 0.1 / dr.Diff);

This ensures that we have a 0 value as the min value of the visible range and we have a padding of 10% on the maximum side when we trigger the ZoomExtentsModifier. When I did this, I was not in an MVVM environment and I was using the NumericAxis type.

Since then, I moved to an MVVM environment and I am now using the NumericAxisViewModel type instead. But now, with this type do not have access to the GetMaximumRange() function. I need this function because in my example above it would return the visible range computed by the auto range which would be (67, 71).

Is this something we could achieve?

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.