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!

0
0

Hello again! 🙂

This time I am trying to draw marker for a maximum numeric data value in chart with CategoryDateTime X axis.

I have my X axis defined like this:

id<SCIAxis2D> xAxis = [[SCICategoryDateTimeAxis alloc] init];

and I am trying to draw a marker in draw() method of a custom modifier using this code:

 id<SCIRenderPassData> data = [_rSeries currentRenderPassData];
 id<SCICoordinateCalculator> xCalc = [data xCoordinateCalculator];
 id<SCICoordinateCalculator> yCalc = [data yCoordinateCalculator];
 NSLog(@"Is category calc: %d", [xCalc isCategoryAxisCalculator]);
 double xCoord = [xCalc getCoordinateFromDate:_xValue];
 double yCoord = [yCalc getCoordinateFrom:_yValue];
 [_marker drawToContext:context AtX:xCoord Y:yCoord];

My _xValue is computed and set from outside and is for sure is a valid date on X axis for which I need to draw the marker on.

My problem is that:

  1. xCoord is always 0.
  2. NSLog line prints 0 to debug console, meaning that xCalc is not CategoryAxisCalculator. I suspect this is why xCoord is always 0.

My questions are:

  1. Am I trying to compute xCoord the right way? I need it for drawing the marker and I have a date for which I want marker to be placed on.
  2. Why [data xCoordinateCalculator] returns something that is not CategoryAxisCalculator even though my axis is a category axis? Is this expected behaviour?

Looking forward to your always useful reply. 🙂

Version
1.2.4
  • You must to post comments
0
0

I managed to solve the problem by manually finding the index of the NSDate* I need to plot the marker on, injecting it as _xValue into derived modifier class and then doing this CoordinateCalculator accrobatics:

id<SCICoordinateCalculator> xCalc = [[parent.xAxes getAxisById:@"xAxis"] getCurrentCoordinateCalculator];

where parent is my SCIRenderSurface.

Can’t we do this without dependency on parent render surface?

Best,
Igor

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.