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

Incorrect datetime label/tick position after using formatter function

Open Farshad-Hasanpour opened this issue 3 years ago • 4 comments

Description

Steps to Reproduce

  1. use xaxis.type: 'datetime' for the chart
  2. add a xaxis.labels.formatter function to customize labels

Expected Behavior

after using xaxis.labels.formatter function I expected every label of the x-axis to stay in the same place and only the text for each one of them to be calculated according to the formatter function. This is needed to use another calendar type for example Jalaali instead of the usual Gregorian calendar

Actual Behavior

after using xaxis.labels.formatter, the position of each DateTime label and also the total number of labels is changed.

Screenshots

image

Reproduction Link

https://codepen.io/farshad-hasanpour/pen/MWENZVg

Farshad-Hasanpour avatar Jan 23 '22 11:01 Farshad-Hasanpour

For what it's worth, this bug-- and I completely agree this is a bug, there's no reason whatsoever that the well-spaced timestamps that the chart uses without a formatter should shift when a formatter is added --appears to stem from this line. When the xaxis.labels.formatter configuration is not undefined, the context's TimeScale object is not initialized, the recalcDimensionsBasedOnFormat method is not called and the globals.timescaleLabels array is never properly constructed.

What is the point of the check on line 558 of Core.js? Why would we not bother setting up the proper timescale ticks whenever the x-axis is a datetime axis? Can that line just be removed?

milotoor avatar Feb 22 '24 19:02 milotoor

Any update on this? Did anyone manage to solve it via a workarround ?

jimmykane avatar Dec 05 '24 08:12 jimmykane

Any update on this? Did anyone manage to solve it via a workarround ?

I disabled zooming and panning features then used the 'tickAmount' to create equal date points between min and max date.

Farshad-Hasanpour avatar Dec 05 '24 08:12 Farshad-Hasanpour

@Farshad-Hasanpour that was what I wanted to avoid :-(

jimmykane avatar Dec 05 '24 09:12 jimmykane