Pre loader

Is it possible to set a lower limit to the yaxis range rather than only the min/max value of the yaxis?


We have a motion sensor for which we present a real time graph. As can be seen from the attached image, my YAxis configuration (auto range) causes the yaxis scale to display noise in a way that is rather disturbing (see attached image).
I have tried to do some fiddling with the axis settings, but with no luck so far.
The YAxis perfectly follows the measured data, but when there is practically no motion, the graph should be shown as an almost straight line, preferably not in the upper or lower end of the scale.

  • Morten Skille
    Example: The sensor has stabilized on a heading value around 234 degrees. The data value range is 233.97 to 234.03 degrees. My implementation will cause the YAxis to be from 233.97 to 234.03 degrees, and the full range of “noise” will be drawn in the graph. I would rather have an YAxis limited to show e.g. a range of 0.5 to 1 degrees, which would cause an almost straight line to be displayed. And I would also like the visual range of the YAxis to be set in a way that the straight line appears close to the middle of the yaxis after a period of turn, say from 225 to 233 degrees. I am pretty sure this is not a new problem for SciChart users, but as a novise user, I have not managed to find an article on the forum that helps. Any hint is highly appreciated.
  • You must to post comments

Hi Morten,

I know I’ve emailed you about this! For the benefit of our community, and search, please find an answer below.

We do this in one of our applications. This is where we want to AutoRange, but to clamp the YAxis Minimum to zero.

            <s:NumericAxis GrowBy="0.0, 0.1" AutoRange="Always" 
                           VisibleRangeLimit="0, 0" VisibleRangeLimitMode="Min"  />

The VisibleRangeLimit / VisibleRangeLimitMode can handle this. VisibleRange Limit Documentation is here.

There are a few suggestions in the documentation above.

Any questions please ask!

Best regards,

  • You must to post comments

Thank you Andrew, that article really helped.
I added MinimalZoomConstrain to the YAxis style, and now the noise is not as visible.

            <SciChart:NumericAxis Style="{StaticResource yAxisStyle}"
                                  GrowBy="0.05, 0.05"
                                  VisibleRange="{Binding ChartYVisibleRange, Mode=OneWayToSource}"
                                  MajorDelta="{Binding ChartYMajorDelta, Mode=TwoWay}"
                                  MinorDelta="{Binding ChartYMinorDelta, Mode=TwoWay}">

Is it possible to have autoscaling trying to position the graph towards the vertical center of the graph viewport?
See attached graph of vertical position.

  • You must to post comments

Image attached now.

  • Andrew Burnett-Thompson
    I would look into the ViewportManager API. Here you can override the AutoRange calcs. Call the base to get what SciChart thinks is the AutoRange range, then manipulate it. Let me know if you have any questions!
  • You must to post comments

I am not sure I have understud how to use available information. The following code was written to experiment with OnCalculateNewYRange(), but it does not seem to have any positive effect on my graphs:

      protected override IRange OnCalculateNewYRange(IAxis yAxis, RenderPassInfo renderPass)
     var baseRange = base.OnCalculateNewYRange(yAxis, renderPass) as IRange<double>;
     if (renderPass.DataSeries == null || baseRange == null) return baseRange;

     var latest = renderPass.DataSeries.LastOrDefault();
     if (latest?.LatestYValue == null) return baseRange;

     var t = latest.GetType();
     var min = (double)latest.YMin;
     var max = (double)latest.YMax;
     if (min > max) return baseRange;

     var diff = baseRange.Diff;
     if (double.IsInfinity(diff)) return baseRange;
     var lastValue = (double)latest.LatestYValue;

     if (Math.Abs(baseRange.Max - max) > diff * .7)
        // max of timeseries much lower than max of yaxis, so have lower limit increase;
        baseRange.GrowBy(-0.1, 0);
     else if (Math.Abs(baseRange.Min - min) > diff * .7)
        //min of timeseries much higher than min of yaxis, so have upper limit decrease
        baseRange.GrowBy(0, -0.1);
     else if (baseRange.Max - lastValue < diff * .1)
        // value close to upper limit - pan y axis upwards
        baseRange.GrowBy(-0.1, 0.1);
     else if (lastValue - baseRange.Min < diff * .1)
        // value close to lower limit - pan y axis downwards
        baseRange.GrowBy(0.1, -0.1);

     return baseRange;

This method is called, but it does not have the effect I expected. (see new attached image)

  • Morten Skille
    Silly me: was better when I assigned baseRange.GrowBy() to a var newRange and returned that instead ;-)
  • You must to post comments

I still have the problem that if measured value is below initial yaxis range, y axis is not changed until I have moved the sensor. What have I missed?
(see next figure)

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies