SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components



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

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

  • Andrew
    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

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.