Search code examples
javascriptamchartsamcharts5

amCharts 5: Is is possible to rotate axes tick labels?


Is is possible to rotate axes tick labels in amCharts 5? E.g.

enter image description here

I am unable to find this mentioned anywhere in the new amCharts 5 documentation. This was possible in amCharts 4.


Solution

  • This can be achieved by setting the rotation property on the relevant axis-renderer's labels.template, eg:

    //...
    const xAxisRenderer = am5xy.AxisRendererX.new(root, {});
    
    xAxisRenderer.labels.template.setAll({
      rotation: -45,
    });
    
    const xAxis = chart.xAxes.push(
      am5xy.CategoryAxis.new(root, {
        renderer: xAxisRenderer ,
        categoryField: 'category-name-here',
      })
    );
    //...
    

    Found via: amCharts 5 demo