J_Code_2025
Posts: 4
Joined: Mon Sep 09, 2024 12:52 pm

How to prevent the columns to stretch up to the size of the whole chart if less data is provided?

I dont display static data and as such the size of the data varies. I show data for each month (xAxis) and year (yAxis). When the data only fills one row (lets say I have January-December) for only 2024, then the colums stretch up to the end of the chart. How can I prevent that, so the cells stay same size?

An example of what I mean: https://jsfiddle.net/L4e3rw2o/

Thank you!
Attachments
Screenshot 2024-09-10 at 18.28.05.png
Screenshot 2024-09-10 at 18.28.05.png (58.86 KiB) Viewed 676 times
andrzej.b
Posts: 150
Joined: Mon Jul 15, 2024 12:34 pm

Re: How to prevent the columns to stretch up to the size of the whole chart if less data is provided?

Hi,

Thanks for contacting us with your question!

The stretching you mentioned is a default behaviour, but there is a way around it: you can set the size of the plot area, and preset the min and max values of each axis to get constant cell sizes, please see a sample fiddle implementation: https://jsfiddle.net/andrzej_b/yehf5mg1/

I hope you will find it useful.

Best regards,
Andrzej

Return to “Highcharts Usage”