Skip to content

yaxis labels duplicated with a formatter function #4422

Closed
@tmac12

Description

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions