Milosz Wojcik
Posts: 24
Joined: Tue Jul 28, 2020 11:21 am

Adding a label to the export flie

Hey,

I want to add a couple of labels to the export file.

I made a jsfiddle example https://jsfiddle.net/x37ue1ps/12/

Issue:
1. Download png file - note that the label is at 5%
2. Change the time range eg. (from 2008-05-25 to 2008-08-22) - note that the label is no longer at 5%

Is there any way to position it correctly on the time range change?

Thanks!
User avatar
sebastian.h
Posts: 1734
Joined: Fri Aug 07, 2020 7:08 am

Re: Adding a label to the export flie

Hi,
Thanks for your questions and example.
Is there any way to position it correctly on the time range change?
Could you explain preciously what that means?

When I export the chart to file everything looks right.

I'm waiting for news from you.
Best regards.
Sebastian Hajdus
Highcharts Developer
Milosz Wojcik
Posts: 24
Joined: Tue Jul 28, 2020 11:21 am

Re: Adding a label to the export flie

Hi,

My goal is to position the label dynamically based on the last point value from the series.

But for now, I just wanted to make some POC and display just one label on the Y-axis at the fixed position eg. 5%.
Like on the screenshot below:
Screen Shot 2021-02-03 at 15.23.57.png
Screen Shot 2021-02-03 at 15.23.57.png (182.99 KiB) Viewed 420 times
It looks fine. To download this just open the fiddle, and download the PNG image (Don't change the time range)

When you change the time range to May 14th 2009 -> May 14th 2010 (or just use dropdown) next export the file one more time, the label is rendered at the wrong place on the Y-axis
Screen Shot 2021-02-03 at 15.24.20.png
Screen Shot 2021-02-03 at 15.24.20.png (217.02 KiB) Viewed 420 times
Unfortunately i didn't find any workaround for that yet...
User avatar
sebastian.h
Posts: 1734
Joined: Fri Aug 07, 2020 7:08 am

Re: Adding a label to the export flie

Hi Milosz!
Thanks for explaining, now it's clear.

At the beginning, I checked how the label rendering works outside the export option.
It seems that it is enough to change the event from load() to render(), you can read more about it in the documentation.
https://api.highcharts.com/highstock/ch ... nts.render

Live demo:
https://jsfiddle.net/BlackLabel/4k6tufms/

Let me know if this solution suits you.
Best regards.
Sebastian Hajdus
Highcharts Developer
Milosz Wojcik
Posts: 24
Joined: Tue Jul 28, 2020 11:21 am

Re: Adding a label to the export flie

Hi,

cool! That's perfect!

Thank you
User avatar
sebastian.h
Posts: 1734
Joined: Fri Aug 07, 2020 7:08 am

Re: Adding a label to the export flie

That's great to hear!

In case of any further questions, feel free to contact us again.
Sebastian Hajdus
Highcharts Developer

Return to “Highcharts Stock”