Apexcharts.js: Bar Chart : Labels are displayed with decimal values when the highest series data is less than 5

Created on 25 Jul 2019  路  2Comments  路  Source: apexcharts/apexcharts.js

image

I am using Apex Chart's Distributed Column Chart

This is the data value I provided in series:

series: [{ data: [4, 1] }],

From this data, I am expecting the labels on Y-axis to be rendered as 0, 1, 2, 3, 4 but that doesn't seem to happen. I tried putting the highest value to 5 in the data array and it rendered correctly.

So the problem here is that I am not able to handle the case when highest value is less than 5 as in the series above for [4, 1].

I tried formatter callback for labels where I used Math.floor() but that didn't work either as it displayed 0, 0, 1, 2, 3, 4

Thanks

yaxis

Most helpful comment

yaxis: {
  labels: {
    formatter: function(val) {
      return Math.floor(val)
    }
  }
}

works fine.

Closing as duplicate of #779

All 2 comments

I stumble upon the same issue. This solution fixed my problem tho

yaxis: {
  labels: {
    formatter: function(val) {
      return Math.floor(val)
    }
  }
}

works fine.

Closing as duplicate of #779

Was this page helpful?
0 / 5 - 0 ratings

Related issues

felixalguzman picture felixalguzman  路  3Comments

pribilinskiy picture pribilinskiy  路  3Comments

thellimist picture thellimist  路  3Comments

ismaildervisoglu picture ismaildervisoglu  路  3Comments

EroTiXx picture EroTiXx  路  3Comments