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!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

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