apexcharts.js icon indicating copy to clipboard operation
apexcharts.js copied to clipboard

xaxis labels formatter inconsistent arguments

Open andrewgoz opened this issue 1 year ago • 0 comments

Description

When options.xaxis.labels.formatter is provided, the arguments passed to the function are inconsistent. This is causing crashes when attempting to access "opts.w".

Steps to Reproduce

  1. https://codepen.io/andrewg_oz/pen/MWZeEaW
  2. View browser console log

Expected Behavior

The formatter is documented as having the arguments "value, timestamp, opts". I expect all calls to that function to be with arguments that are consistent on a per-chart basis. I expect value to be sensible for all calls, timestamp to be either undefined for all calls or sensible for all calls (not both), and opts to be the same for all calls (depending on what "i" is supposed to be).

Actual Behavior

The example exhibits five(!) different calls with varying arguments to the formatter:

  1. value is defined with an expected value, timestamp undefined, opts undefined
  2. value is defined, but a strange value, timestamp undefined, opts undefined
  3. value is defined with an expected value, timestamp defined, opts defined as an Object with i undefined, w defined, and dateFormatter defined
  4. value is defined with an expected value, timestamp defined, opts defined as an Object with i defined, w defined, and dateFormatter defined
  5. when hovering over the chart, value is defined, timestamp is defined as an Object - not a number - with properties "series, seriesIndex, dataPointIndex, and w", and opts is undefined

In short, calls to this formatter are a complete mess.

Reproduction Link

https://codepen.io/andrewg_oz/pen/MWZeEaW

andrewgoz avatar Sep 01 '23 05:09 andrewgoz