Help with setting up the date axis on Charts to handle lots of data and almost no data

I have a line chart that uses LocalDate and I want the x axis to show the months (or possibly years if it’s say 5+ years of data). With that in mind if I do nothing in terms of units it works great if there is a decent amount of data, say a year’s worth. However if say I only have a few entries for a few days then the label will default to days, or even hours if it’s just a couple of days which is not good. I want the labels to be months at a minimum.

To deal with this I added configuration.getxAxis().setUnits(new TimeUnitMultiples(TimeUnit.MONTH, 1), new TimeUnitMultiples(TimeUnit.YEAR, 1));

The challenge is that when I do this if there is more than a year of data then the x axis labels all start to overlap and so on and nothing is readable. In this case it would be ideal to not label every month and maybe just every few months, or just years if it’s 5-10 years or more.

I’ve tried everything I could to cover both cases playing with tick intervals, min tik interval, to you name it but nothing seems to work. Any help in trying to do this would be greatly appreciated.