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

Column chart with datetime on x axis breaks annotation positioning on y axis

Open onetdev opened this issue 1 year ago • 3 comments

Description

Annotation starts from the middle of the first column and stops at the middle of last. This doesn't seem to affect other xaxis types.

Steps to Reproduce

  1. Have a chart that uses the following configs:
var options = {
  xaxis: {
    type: "datetime",
  },
  annotations: {
    yaxis: [
      {
        y: 0,
        y2: 100,
        borderColor: "red",
        strokeDashArray: 0,
      }
    ],
  },
  ....
};

Expected Behavior

The annotation to start from the left edge of the grid and finish on the right edge

Actual Behavior

Annotation starts from the middle of the first column and stops at the middle of last.

Screenshots

The issue with datetime type

image

This is how numeric looks:

image

Reproduction Link

https://codepen.io/onetdev/pen/xxNOvZr

onetdev avatar May 24 '24 07:05 onetdev

There is a difference in how the bars are drawn in a category x-axis vs datetime x-axis. Due to that difference, the position of the annotations changes based on that.

junedchhipa avatar May 31 '24 10:05 junedchhipa

is there anyway to fix this? the problem i'm having now is if you now add zoom in a column chart with datetime xaxis, the zoom result is always off by the offset.

xysun avatar Jul 12 '24 15:07 xysun

I have the same issue: (see screenshot below) Does anybody know a workaround to fix it? I tried to set the offsetX of the annotation to a negative value but since the amount of bars differ for each graph (can be between 2 and 50) this does not work.

Screenshot from 2024-07-24 15-47-38

x-axis is set to category. for me it seems to break by setting tickPlacement: 'on', instead of 'between'. When I use 'between' it does work correctly but I can't to that because I need 'on' because I need the zoom functionality. (https://apexcharts.com/docs/zooming-in-category-x-axis/)

JorindeUsMedia avatar Jul 24 '24 13:07 JorindeUsMedia