SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components
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.
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?
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
Please login first to submit.