Pre loader

Coordinate relative line annotation

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

1
0

Hello!

Please take a look at the attached screenshot first.

I have a chart configured to draw real-time trading data. X axis type is DateTime. Y axis type is Float. I need to draw vertical expiration time line.

I tried to draw coordinate relative line annotation as follows:

var date: NSDate = NSDate()

let lineAnnotation = SCILineAnnotation()
lineAnnotation.xAxisId = self.axisXId
lineAnnotation.yAxisId = self.axisYId
lineAnnotation.coordMode = .SCIAnnotationCoord_RelativeX
lineAnnotation.style.linePen = SCIPenSolid(color: Style.Chart.ExpirationDateLine.Color, width: Style.Chart.ExpirationDateLine.Width
lineAnnotation.xStart = SCI_constructGenericTypeWithInfo(&date, .DateTime)
lineAnnotation.xEnd = SCI_constructGenericTypeWithInfo(&date, .DateT            

self.chartSurface.annotation = lineAnnotation
self.chartSurface.invalidateElement()

I tried to play with different coordMode values. Line does not appear. Could you help me with this task?

Version
v1.0.0.492
Images
  • Andrew Burnett-Thompson
    Hello! It’s quite common for people to assign AxisId to an annotation when they haven’t assigned one to an Axis (or vice versa). Can you either leave Axis IDs all default, or, check if they’re all the same? Cross check SCIAxisBase.axisId vs. your xAxisId and yAxisId on the lineAnnotation. By default, and in single axis scenarios, all IDs should be set to SCIAxisBase.defaultAxisId
  • You must to post comments
2
0

Hello! To fix it you should use SCIAnnotationCoord_RelativeY coord mode. Because, if I get it right you need x coordinate bound to absolute values, and y coordinate relative to screen position
Here is example for swift:

    let line = SCILineAnnotation()
    line.coordMode = SCIAnnotationCoordMode.SCIAnnotationCoord_RelativeY
    line.yStart = SCIGeneric(0)
    line.yEnd = SCIGeneric(1)
    let date = NSDate()
    line.xStart = SCIGeneric(date)
    line.xEnd = SCIGeneric(date)
    line.xAxisId = axisXId
    line.yAxisId = axisYId
    chartSurface.annotation = line

btw, it’s better to use SCIGeneric() function to setup SCIGenericType. It’s just swift wrapper for SCI_constructGenericTypeWithInfo() function

  • 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