Search code examples
angularapexcharts

When formatting x-axis labels in Ng Apex Chart(Angular), x-axis labels are duplicated


I'm using Ng Apex Charts.
In X Axis label the showDuplicates property is set to false because I dont want duplicated x-axis labels.

My data values in x-axis are 0.4, 0.7, 1.2, 1.3, 2, 2.4

I'm using xaxis > labels > formatter function to show only integer values, no matter what data value it is and this is working fine, but the problem is the labels are shown duplicated like this: 0,0,1,1,2,2.

The result I want to be is: 0, 1, 2 in x-axis labels.

Is there any solution?
Thank you.


Solution

  • Set the tickAmount to a lower number if you don't want fractions.

    For eg., If you have x-values from 0 to 3, set

    xaxis: {
      tickAmount: 3
    }