Hello,
I am using a candlestick chart for a financial application and I want to add the sign and price to the highest and lowest price bar that appears on the screen as in the attached image. As the chart is scrolled, the highest price and lowest price data and location should also change. how can I do that?
Best regards.
- devrim çatak asked 1 year ago
- You must login to post comments
Hi Devrim
The best way to do this would be with TextAnnotation and LineAnnotation type.
You would have to calculate the Min/Max in the viewport and position the annotations.
Some ideas how to do this:
Listen to axis visibleRange changes
val axis = NumericAxis(context)
axis.setVisibleRangeChangeListener { axis, oldRange, newRange, isAnimating ->
// TODO handle range changes here
}
calculate min, max inside that visible range and position an annotation on the chart by setting Annotation.X1, X2, Y1, Y2 properties. You can also adjust the TextAnnotation.Text to display the value at the min & max on the chart.
val textAnnotation = TextAnnotation(context)
textAnnotation.text = "Some text"
// Specify a desired position
textAnnotation.x1 = 20
textAnnotation.y1 = 14
// add to the chart
surface.annotations.add(textAnnotation)
Finally, be aware of Annotation.HorizontalAnchorPoint / VerticalAnchorPoint which allows you to align a TextAnnotation left or right top or bottom
Does that help?
Sorry not a full solution but should point you in the right direction!
Best regards
Andrew
- Andrew Burnett-Thompson answered 1 year ago
- last edited 3 months ago
- You must login to post comments
Please login first to submit.