Search code examples
javascriptamcharts

How to wrap categoryAxis text in amchart v3?


I faced an issue categoryAxis and label text overlaping issue given below I mentioned the code.

"categoryAxis": {
    "gridPosition": "start",
    "labelRotation": 45,
    "autoWrap":true,
},

I uploaded my bug image so anyone please give me a solution to solve this.

Uploaded My Result

Here I mentioned my codepen link so please give me a solution to solve this.

https://codepen.io/arunram860/pen/aMPxKV


Solution

  • You can just use the direct categoryAxis.title and valueAxis.title to create the axis names instead of creating the labels yourself in allLabels.

    var chart = AmCharts.makeChart("chartdiv", {
      // ...
      "valueAxes": [{
        "title": "Id"
      }],
      "categoryAxis": {
        "gridPosition": "start",
        "labelRotation": 45,
        "title": "City Name"
      },
      // ...
    });
    

    Here I forked your code pen to show you the configuration.