NeBox
Posts: 44
Joined: Sun Feb 05, 2023 4:12 am

Chart width in a window

Hi.

You have a great chart. Trying out how it will be on mobile devices.

I noticed that I have no way to set a clear width for it. It changes it dynamically itself and it comes out kind of crooked.

What can I do here to minimize all indents?
Attachments
hc-m.png
hc-m.png (21.46 KiB) Viewed 378 times
User avatar
dawid.d
Posts: 838
Joined: Thu Oct 06, 2022 11:31 am

Re: Chart width in a window

Hi,

I'm glad you like our library!

I tried to reproduce your problem, but to no avail. See the demo below, in my case the margin on the right is the same for both axes. Are you able to share your configuration somehow? You can base on this demo.

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

I'm waiting for your reply!
Best regards!
Dawid Draguła
Highcharts Developer
NeBox
Posts: 44
Joined: Sun Feb 05, 2023 4:12 am

Re: Chart width in a window

Thanks for the answer.

If we set the label on the left side, this happens.

Otherwise the bars go under the label

Code: Select all

Highcharts.stockChart('container', {
	yAxis: [{
    	height: '60%',
			labels: {
				align: 'left'
			}
    }, {
    	top: '60%',
    	height: '40%',
			labels: {
				align: 'left'
			}
    }],
    series: [{
        data: [245345, 6345, 4231, 7345, 964, 53242],
        yAxis: 0
    }, {
    	type: 'column',
		data: [1, 2, 3, 2, 1, 2],
        yAxis: 1
    }]
});
If you don't touch the label settings, the text overlaps the bars
bars.png
bars.png (8.35 KiB) Viewed 316 times
User avatar
dawid.d
Posts: 838
Joined: Thu Oct 06, 2022 11:31 am

Re: Chart width in a window

Hi, thanks, it's all clear now!

So it looks like you need to use the `offset` option here, setting it to 0.

Demo: https://jsfiddle.net/BlackLabel/0vLsktx2/
API Docs: https://api.highcharts.com/highcharts/yAxis.offset

Hope it helps!
Best regards
Dawid Draguła
Highcharts Developer
NeBox
Posts: 44
Joined: Sun Feb 05, 2023 4:12 am

Re: Chart width in a window

Hi.

It's working! Thanks a lot for your help.
I wouldn't have found it myself.

Return to “Highcharts Stock”