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?
- Alexander Edunov asked 8 years ago
- last edited 8 years ago
-
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 login 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
- Andrii Poliuk answered 8 years ago
-
Thanks for your answer! I got expected behavior.
- You must login to post comments
Please login first to submit.