hcrz1022
Posts: 9
Joined: Thu Jan 27, 2022 3:25 pm

xaxis background styling question

I need to set the background of the xaxis bar (the whole bar, not the particular label).
By checking the api doc, it seems only limited properties are supported.
I am trying the following options
https://api.highcharts.com/highstock/xAxis.labels.style

xAxis.labels.style
CSS styles for the label. Use whiteSpace: 'nowrap' to prevent wrapping of category labels. Use textOverflow: 'none' to prevent ellipsis (dots).

In styled mode, the labels are styled with the .highcharts-axis-labels class.

See also:
Highcharts.CSSObject
color: string
Defaults to #666666.
cursor: string
Defaults to default.
fontSize: string
Defaults to 11px.

Maybe there is other option I should use? Any sample code will be appreciated. Thanks.
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: xaxis background styling question

Hi hcrz1022,

Thanks for contacting us with your question.

Do you mean something like this? https://jsfiddle.net/BlackLabel/wgq5hne0/
As you can see in the example, it can be done with SVGRenderer tool.

Let me know if that was what you were looking for! If not, please provide me with more details and preferably a simple illustration.
Regards!
Mateusz Bernacik
Highcharts Developer
hcrz1022
Posts: 9
Joined: Thu Jan 27, 2022 3:25 pm

Re: xaxis background styling question

Thanks so much for responding. The sample chart looks great to me. However, it works on regular high chart, but not the stock chart. I tried to render in stock chart with no luck. Is there any sample for stock chart?
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: xaxis background styling question

hcrz1022,

Sure, I can create such sample, but could you provide me with a live demo with your stock chart? The implementation may vary depending on options that you use. You can insert some random data.

Regards!
Mateusz Bernacik
Highcharts Developer
hcrz1022
Posts: 9
Joined: Thu Jan 27, 2022 3:25 pm

Re: xaxis background styling question

Here please see the sample chart https://jsfiddle.net/rz1022/yno72Lc1/8/
I want to set the background of the buy/sell axis. Thanks.
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: xaxis background styling question

Thanks for the demo. The solution is fairly similar. We just need to choose a correct axis from axis array and make sure that the y position of background is corrected by axis' offset.
Demo: https://jsfiddle.net/BlackLabel/3cyfLbrt/

Let me know if you have any further questions!
Regards!
Mateusz Bernacik
Highcharts Developer
hcrz1022
Posts: 9
Joined: Thu Jan 27, 2022 3:25 pm

Re: xaxis background styling question

Thanks so much, this is really helpful!
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: xaxis background styling question

You're welcome! In case of any further questions, feel free to contact us again.
Mateusz Bernacik
Highcharts Developer
hcrz1022
Posts: 9
Joined: Thu Jan 27, 2022 3:25 pm

Re: xaxis background styling question

The sample works perfect.
Just one more question, it is regarding range selector, it only controls 1 axis for now. Can we apply the range to both axis?
Thanks ahead.
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: xaxis background styling question

hcrz1022,

If I am not wrong, you have already asked that question in this topic: viewtopic.php?f=12&t=48073#p173552
As far as I know, my colleague started working on that topic and you can expect his answer soon. Also the question is quite different from the one in this topic, so I think it is a better idea to keep it as a separated topic, in case if someone looks for similar question.

Thanks for your patience.
Regards!
Mateusz Bernacik
Highcharts Developer

Return to “Highcharts Stock”