Super easy solution without using VBA. This works if you have dates for your x-axis. Use UNIQUE and FILTER to populate the values needed for your x-axis.
In this example, the original x-axis values are in F9:F25. The data values are in G9:G25. In K9, I am using the formula UNIQUE(FILTER(F9:F25,G9:G25<>"")), which results in showing the dates for only the data values that are not empty. Even though the x-axis range is from K9:K25, the chart will stop at the last value in column K.