Pre loader

AutoRange only when exceeding initial VisibleRange

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

0
0

Hi,

Is there any functionality to only increase the YAxis VisibleRange when the displayed data exceeds the initial VisibleRange?

Example: I’ve set the initial VisibleRange of the YAxis to min=0.0 and max=10.0. I don’t want the chart to AutoRange, because this range should be always visible even if the displayed values are smaller. But I want the VisibleRange to be increased by the set GrowBy value if the displayed data is smaller or higher than the initial range.

Is there any built-in functionality or do I have to care about that myself inside of the ViewModel?

Thanks!

  • You must to post comments
0
0

Hi Joerg, the grow-by is a multiplying factor. You could try this:

Instead of

var currentRange = this.YAxis.VisibleRange.AsDoubleRange();
  
if (value > currentRange.Max)
{
    var growByRange = this.YAxis.GrowBy.AsDoubleRange();
    this.YAxis.VisibleRange.SetMinMax(0, currentRange.Max + growByRange.Max);
}

try

// Decouple the instance so you don't modify original
var currentRange = (DoubleRange)this.YAxis.VisibleRange.AsDoubleRange().Clone();
  
if (value > currentRange.Max)
{
    // Expand range
    currentRange.Max = value;
    
    // Apply growby
    currentRange = currentRange.GrowBy(this.YAxis.GrowBy);    

    this.YAxis.VisibleRange.SetMinMax(0, currentRange.Max);
}

Also, a hidden feature in v1.5 will be the ability to put this logic into a “ViewportManager” derived class. This is called by SciChart in the render loop to get the new visible range, so it will be a good place to put this code.

Hope this helps!

  • You must to post comments
Showing 1 result
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