Skip to content

The dataLabels formatter requires type definitions because it allows (string | number)[]. #4801

@daiboom

Description

@daiboom

Description

I try setting the return value of the data label formatter to [val, 1, 'string']. Although a warning appears saying that this is not a valid return type for the formatter, ApexCharts.js actually accepts it and displays it on the chart.

Steps to Reproduce

var options = {
  chart: {
    type: "bar"
  },
  series: [
    {
      name: "sales",
      data: [30, 40, 45, 50, 49, 60, 70, 91, 125]
    }
  ],
  xaxis: {
    categories: [1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999]
  },
  dataLabels: {
    formatter: (val, opt) => {
      return [val, 1, "string"];
    }
  }
};

var chart = new ApexCharts(document.querySelector("#chart"), options);

chart.render();
// apexcharts.d.ts

type ApexDataLabels = {
...
  [-] formatter?(val: string | number | number[], opts?: any): string | number | string[]
  [+] formatter?(val: string | number | number[], opts?: any): string | number | (string | number)[]
}

Reproduction Link

https://codepen.io/choidaeboem/pen/OJKraap

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions