Highcharts does not display all categories

I use HighCharts, but I do not understand why it does not display a category in xAxis if yAxis has no data ...

I checked in the API documentation and showEmpty is true (default value) ...

How can I display all categories even though I have more categories than data?

My js:

userChart = new Highcharts.Chart({ chart : { renderTo: 'highcharts', type: 'line', width: 950 }, xAxis: { categories: ['08:00', '08:30', '09:00', '09:30', '10:00', '10:30', '11:00', '11:30', '12:00', '12:30', '13:00', '13:30', '14:00', '14:30', '15:00', '15:30', '16:00', '16:30', '17:00', '17:30', '18:00'], }, yAxis: { min: 0, allowDecimals: false, }, series: [{ name: '1', data: data1, }], }); 

data1 contains only 16 inputs, so Highcharts displays 16 categories ...

How can i fix this?

+2
source share
1 answer

You can do this by xAxis how many points to show no matter how much data you have. This is a bit of a hack since xAxis does not have exact values, but it has index values ​​for each category starting at 0. So, you have 21 categories, which means that the maximum index is 20. Then you xAxis property will look like this:

 xAxis: { categories: ['08:00', '08:30', '09:00', '09:30', '10:00', '10:30', '11:00', '11:30', '12:00', '12:30', '13:00', '13:30', '14:00', '14:30', '15:00', '15:30', '16:00', '16:30', '17:00', '17:30', '18:00'], min: 0, max: 20 }, 
+3
source

Source: https://habr.com/ru/post/917059/