fresh_ny
Posts: 25
Joined: Wed Jul 06, 2022 4:33 pm

Re: Making labels stick to the X axis

That's very helpful. Which raises another question.

I'm guessing there's a way to update variables in a "live" way as the label is moving? I can add x & y but they only update when first rendered.

https://jsfiddle.net/EstebanTheMagnificent/rh6oyjzp/6/

Also, on some labels I have a line that fixed to the origin point and other labels I don't have it. How do I control it?

Thanks!
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Making labels stick to the X axis

Hi!

I'm sorry that you had to wait for the solution.

Sure, it can be done easily.
Simply, instead of using text property in annotations.labels.text (line 38), use a formatter function where you can provide these values in return.
Check out the demo and API Reference below.

DEMO: https://jsfiddle.net/BlackLabel/d5kte63q/
API Reference: https://api.highcharts.com/highcharts/a ... .formatter

I hope that you will find it useful,
Best regards!
Kamil Musiałowski
Highcharts Developer
fresh_ny
Posts: 25
Joined: Wed Jul 06, 2022 4:33 pm

Re: Making labels stick to the X axis

Hello again!,

I was looking back over this thread as I'm trying to find out if there's a way to place a label relative to the bottom of the chart, rather than the top?

If the chart is dynamic and increases it's height the label ends up floating rather than sitting on the bottom of the chart

https://jsfiddle.net/EstebanTheMagnific ... 79oer/122/

thoughts?
pawelys
Posts: 962
Joined: Wed Sep 02, 2020 10:37 am

Re: Making labels stick to the X axis

Hi! Which label do you mean? Do you want to make the annotation to be positioned in a fixed position? You can achieve it, by setting y value without setting yAxis. Then, the values you set are pixels, counted from the top of the chart. Does it work for you?
Paweł Lysy
Highcharts Developer
fresh_ny
Posts: 25
Joined: Wed Jul 06, 2022 4:33 pm

Re: Making labels stick to the X axis

Hi, I know how to set a fixed position from the top, but I was looking for a fixed position from the bottom.

In the fiddler example I was looking to use the multi line label
hubert.k
Posts: 1164
Joined: Mon Apr 11, 2022 11:48 am

Re: Making labels stick to the X axis

Hi fresh_ny!
Sorry, for the slightly longer response time! You can add/update the annotations in the load event to calculate their place based on e.g. chart.height.

Demo: https://jsfiddle.net/BlackLabel/m2k8z1Le/

The this object has the properties, which say what is the size of the container nad chart, so you can base on them.

In case of any further questions, feel free to ask.
Kind regards!
Hubert Kozik
Highcharts Developer

Return to “Highcharts Stock”