apexcharts / apexcharts.js

📊 Interactive JavaScript Charts built on SVG
https://apexcharts.com
MIT License
14.05k stars 1.28k forks source link

yaxis labels duplicated with a formatter function #4422

Open tmac12 opened 2 months ago

tmac12 commented 2 months ago

Description

When yaxis.labels.formatter is provided, in some case it duplicate values on yaxis. In my example, I receive y-axis data in seconds and need to display it on the chart in hours, so I use a formatter for this conversion. However, this results in some integer values being duplicated.

Steps to Reproduce

  1. codepen link
    chart: {
    height: 380,
    width: "100%",
    type: "bar"
    },
    series: [
    {
      name: 'Incoming',
      data: [
        {
          x: '0-3200 rpm',
          y: 15417,
        },
        {
          x: '3200-6400 rpm',
          y: 1498,
        },
        {
          x: '6400-9600 rpm',
          y: 19038,
        },
        {
          x: '9600-12800 rpm',
          y: 19119,
        },
      ],
    }
    ],
    yaxis:{
    labels:{
      formatter: function(value){
        //console.log(value);
        var d = value;
        var dd = d / 3600;
        var rnd = Math.round(dd);
        return rnd.toString() + ' h';
      }
    }
    }
    }

Expected Behavior

The formatter show only unique values on yaxis.

Actual Behavior

On yaxis I see duplicated values only if formatter function is provided.

Screenshots

image

Reproduction Link

https://codepen.io/bortolazzoBreton/pen/qBwLajb

github-actions[bot] commented 3 days ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.