Juan,
You can set indexLabelOrientation property to “vertical” or “horizontal” depending on the number of datapoints and update the chart options. Please find the code snippet below,
if(chart.options.data[0].dataPoints.length > 15)
chart.options.data[0].indexLabelOrientation = "vertical";
else
chart.options.data[0].indexLabelOrientation = "horizontal";
chart.render();
Please take a look at this JSFiddle for working example.

—
Adithya Menon
Team CanvasJS