Pre loader

Range / Annotation that is always visible in a chart

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,

i have an horizontal line annotation in my chart at a fixed value (some hint for the user “minimum level”) that i always want to be visible. Thus, i’d like to set the axis/chart so that it always shows a range from 0 to 0.05, or larger range if the chart values exceed this range.
I’ve tried to set-up the VisualRangeLimit property to fit my needs but could not achieve my goal.

<s:NumericAxis AxisAlignment="Left"
               Id="MagnitudeAxis"
               VisibleRangeLimit="0, 0.05"
               AxisTitle="{lex:Loc MagnitudeAxisLabel}" />

Are there other options to achieve this or am i doing somthing wrong?

Version
4.2.3.9840
  • You must to post comments
0
0

Hi Martin,

VisibleRangeLimit has some caveats. Basically it is used to control the limit of AutoRange, but does not prevent user zooming outside of this range.

If you want to force a hard limit for one side, or both sides of the axis for all conditions (including zooming, panning and autorange), then try this technique:

Clipping the Axis.VisibleRange on Zoom and Pan

Advanced VisibleRange Clipping and Manipulation

Axis.VisibleRangeLimit is a useful API to ensure the axis clips the VisibleRange when zooming to extents. However, it will not stop a user from scrolling outside of that range. To achieve that, you need a small modification:

Clipping Axis.VisibleRange in 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);
   }
};

We also have a solution on the same page for clipping the axis range in MVVM.

Best regards,
Andrew

  • Martin Godec
    Dear Andrew, thanks for the support! I solved the issue by binding directly to a DoubleRange property in the ViewModel and calculating the Range everytime new data is added to the chart. Actually, zooming/panning is currently not enabled for my chart but i will reconsider the MVVM solution if this is a topic in the future. Best regards, Martin
  • Andrew Burnett-Thompson
    Sounds great! Yes that’s another way of doing it. Basically the problem boils down to ‘control VisibleRange’ :) Best regards, Andrew
  • 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