Hi,
ich would like to draw annotations for min/max-prices on a chart like the attached image. I got pretty close to the screen but I have two questions:
1. is there a way to automatically such min/-max-annoations (currently I determine min and max values manually and then draw the annotation at the respective x/y coordinates)
2. How can I make sure those annotations are visisble; currently I use growBy(0.1, 0.1) on each axis to have some room for the labels, but that seems pretty unreliable.
Regards
Benjamin
- Benjamin Mesing asked 6 months ago
- You must login to post comments
Hello Maulik Senghani,
thank you for your response and the hint towards Min, max, that solve the data question.
With regards to your second answer: I do not fully understand your proposed solution: visible range is in the y-Data-Type i.e. currency (10-20€) but the annotation height is in pixel/unit. So I cannot increment the visible range without converting the pixel value to a currency-Value. Do you propose to do some kind of calculation like this:
annotation_height_in_currency =
(visible_range_in_currency / chart_size_in_pixel) * annotation_height_in_pixel
I had hoped for a more conveneint solution.
Regards
Benjamin
- Benjamin Mesing answered 5 months ago
- last edited 5 months ago
- You must login to post comments
Hi Benjamin Mesing,
Regarding the points you mentioned:
-
You can obtain the minimum and maximum values from the renderable series using renderableSeries.getYRange(). From this, you can retrieve the minimum and maximum values with getMin() and getMax(). If the chart is scrollable and annotations are placed based on the current visible range, you will need to manually calculate the min and max values based on the visible range. You can listen for changes in the visible range by using setVisibleRangeChangeListener on the axis.
-
To make the annotations visible, you can set the visible range to:
2 × (height of annotations) + padding
You can find some useful documentations below.
visibleRangeChangeListener
IRange Class
- Maulik Senghani answered 6 months ago
- You must login to post comments
Hi Maulik,
thank you for your response, the first answer is already helping.
For the second answer there is one thing I do not understand: as far as I know, “visible range” is e.g. 5€-10€ while “height of annotation” is in pixel. So I would have to calculate the “visible annotation-height” by (range/chart-height-in-pixel)*annotation-height-in-pixel (especially do not like having the chart-height in this formula). Is there an easier way (like adding an axis-padding -in-pixel or having a zoom-fit-to-annotations method)
.
Regards
Benjamin
- Benjamin Mesing answered 6 months ago
- last edited 5 months ago
- You must login to post comments
Please login first to submit.