Search code examples
anychart

How to move the x-axis labels on a datetime scale further from the edges?


I have this chart: https://playground.anychart.com/D7okDBpO/2

I would like the plot and x-axis labels to have some padding from the left and right edges (one of the reasons is that the last x-label is not even fully visible right now), similarly to how a chart with ordinal scale is rendered. For the plot I managed to do this with:

series.left(30);
series.right(30);

But I can't find a solution for the x labels. What I've tried:

// This doesn't work because it moves both first and last label
chart.xAxis().labels().offsetX(-30);

// This doesn't work because it moves all the labels, even the ones in the middle
chart.xAxis().labels().padding().left(50);

Solution

  • are you looking for this setting:

    chart.left(20);
    chart.right(20);
    

    https://playground.anychart.com/miB1VAbq ?