Pre loader

How to find YAxis Range dependent on XAxis Range

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

I currently have a DateTime X axis on my SciChart and a Numeric Y Axis.

When I call YAxis.DataSet.YRange, I get correct values based on the data tied to the axis.

If I do the same with the X axis, XAxis.DataSet.XRange, I get the following value for both the Min and Max: ~6.34E+17.

Is this a bug, or is there a better way to get the correct values for the extents of the axes?

The intention is to implement ZoomToFit type function only related to that axis. I did not see this in the API. Is there an easier way to do it for all axis types?

  • You must to post comments
0
0

Hi Mike,

Thanks for your enquiry! Yes the DataSet.XRange / YRange properties return the extents of the data for the entire DataSet in X or Y (it does not discriminate between series on different axes). Also XRange, YRange are of type DoubleRange regardless of the type of the TX,TY in the DataSet.

The DataSet.XRange is returning a DoubleRange with tick values corresponding to your DateTimes. E.g. +6.34E+17 corresponds to approx January 2010, therefore new DateTime((long)DataSet.XRange.Min) is equal to the min date.

There are functions throughout the API which can assist in getting axis ranges to perform zoom to fit. For instance:

AxisBase.GetMaximumRange

/// <summary>
/// Gets the Maximum Range of the axis, which is equal to the DataRange including any GrowBy factor applied
/// </summary>
/// <returns></returns>
public abstract IRange GetMaximumRange();

DataSeries.GetWindowedYRange(IRange visibleXRange)

/// <summary>
/// Gets the YRange of the data (min, max of the series) in the input visible range point range, where the input range is the <see cref="IAxis.VisibleRange"/>
/// </summary>
/// <param name="xRange">The X-Axis Range currently in view</param>
/// <returns>The YRange of the data in this window</returns>
/// <exception cref="System.ArgumentNullException">xRange</exception>
/// <exception cref="System.InvalidOperationException">Invalid Range Type. Please ensure you are using DateTimeAxis where the X-Data is DateTime, and NumericAxis where the X-Data is Double, Float, Int, Long</exception>
public IRange GetWindowedYRange(IRange xRange);

DataSeries.GetWindowedYRange(IndexRange indicesRange)

/// <summary>
/// Gets the YRange of the data (min, max of the series) in the input IndexRange, where indices are point-indices on the DataSeries columns
/// </summary>
/// <param name="xIndexRange">The X-Axis Indices currently in view</param>
/// <returns>
/// The YRange of the data in this window
/// </returns>
public IRange GetWindowedYRange(IndexRange xIndexRange);

Also if you’re interested in writing custom zoom to fit, I would suggest looking at the source code (which you have access to), SciChartSurface.ZoomExtents(), ZoomExtentsY() methods as these have custom logic in them to determine zoom to fit on a per-axis basis.

Hope this helps!
Andrew

  • Mike Melancon
    Thanks Andrew, I didn't realize they were given using ticks. I also didn't think to look in the source...
  • Andrew Burnett-Thompson
    No worries, feel free to ask, we know it well! BTW Yuriy is just finishing up work on the Axis API now. He has added (for SciChart v2.0) a suite of axis-specific functions to Zoom, Pan, Scroll. If you have any other ideas through your work, e.g. use cases you had to write ugly code to achieve, do let me know. 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