Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
daiboom opened this issue Nov 12, 2024 · 0 comments · Fixed by #4802
Closed
Labels
bug Something isn't working

Comments

@daiboom
Copy link
Contributor

daiboom commented Nov 12, 2024

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

@daiboom daiboom added the bug Something isn't working label Nov 12, 2024
@daiboom daiboom changed the title dataLabels formatter는 (string | number)[] 를 허용하기때문에 타입정의가 필요합니다. The dataLabels formatter requires type definitions because it allows (string | number)[]. Nov 12, 2024
daiboom added a commit to daiboom/apexcharts.js that referenced this issue Nov 12, 2024
…een redefined from string[] to (string | number)[].
junedchhipa added a commit that referenced this issue Nov 21, 2024
…-type-redefine

fix:#4801 The return type of the dataLabels formatter has been redefine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant