SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & 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,

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
    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.