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

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

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.