Pre loader

XAxis.VisibleRange.SetMinMax and GetCoordinate() of GetCurrentCoordinateCalculator

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

Answered
1
0

I have a chart with a range of 0..1000(xAxis)
Secondly i call;

var xCalc = this.XAxis.GetCurrentCoordinateCalculator();
double xDataValue = xCalc.GetCoordinate(500);

xDataValue is for example equal 500;

Next step:
I change the range via:

XAxis.VisibleRange.SetMinMax(1000,2000)
// Secondly i call;
var xCalc = this.XAxis.GetCurrentCoordinateCalculator();
double xDataValue = xCalc.GetCoordinate(1500);

xDataValue shall also be equal 500 or? (but it is negative -XXX)???

I call

SciChart.XAxis.VisibleRange.SetMinMax(min, max);

in my ChartViewModel and

var xCalc = this.XAxis.GetCurrentCoordinateCalculator();
double xDataValue = xCalc.GetCoordinate(1500);

in my ChartModifier..

  • You must to post comments
Best Answer
0
0

Hi Daniel,

The method Axis.GetCurrentCoordinateCalculator() returns the CoordinateCalculator instance for the current axis and visible range, but … this instance is only updated when the Axis is redrawn (when a new render pass occurs). We do this for performance reasons – by caching the CoordinateCalculator instance.

So its possible that you are getting the CoordinateCalculator but before it has been updated.

Can you try this? Try calling AxisBase.OnBeginRenderPass(). This will flush the CoordinateCalculator instance and ensure a new one is created.

// Get CoordinateCalculator instance
var xCalc = this.XAxis.GetCurrentCoordinateCalculator();
double xDataValue = xCalc.GetCoordinate(500);

// Change VisibleRange
XAxis.VisibleRange.SetMinMax(1000,2000)

var xCalc2 = this.XAxis.GetCurrentCoordinateCalculator();

// Ensure creation of new coordinate calculator
this.XAxis.OnBeginRenderPass(); 
var xCalc3 = this.XAxis.GetCurrentCoordinateCalculator();
double xDataValue = xCalc3.GetCoordinate(1500);

// Some assertions
Debug.Assert(ReferenceEquals(xCalc, xCalc2) == true);
Debug.Assert(ReferenceEquals(xCalc, xCalc3) == false);

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