Apexcharts.js: xaxis last label is trimmed

Created on 5 Feb 2019  路  17Comments  路  Source: apexcharts/apexcharts.js

Codepen

Showcase codepen

Explanation

The showcase codepen uses the current versions of Vue-ApexCharts and ApexCharts.js, the expected behavior uses v1.1.0

  • What is the behavior you expect?

Correct result codepen

The x axis sets the first and last point to be at the edge of the grid in the current version of Vue-ApexCharts, whereas the version showcased in the demos (that's where I picked the initial code) correctly sets the labels and the datapoints to have enough offset on both sides so that no clipping occurs.

  • What is happening instead?

Edge points and labels are clipped.

  • What error message are you getting?

None.

Edit: Let me know if I should submit this to the Vue-ApexCharts repo instead.

Edit2: after fiddling with codepen, I can say this is an apexcharts issue, not the Vue component. This codepen uses apexcharts v3.1.0 and displays fine. It breaks starting with 3.2.0.

Edit3: I found that a property was added in 3.2.0 (xaxis.tickPlacement), which defaults to 'on', whereas the old behavior for a line chart was to have it as 'between'. The documentation isn't reflecting this, nor does it mention the existence of xaxis.tickPlacement. May I suggest that:
1) Default for line should be set to 'between'
2) Documentation should be updated ?

bug

Most helpful comment

This issue should not be closed. I am seeing this bug on fresh installation of latest apex chart 3.20.0 and vue-apexcharts 1.6.0, with datetime type x data on a line chart. I used the workaround

.apexcharts-xaxis-label:nth-last-child(2) {
  transform: translateX(-20px)
}

All 17 comments

Thanks for reporting the issue.
I think, providing some padding on the right side when the last label is long will prevent it being cropped.
I will surely update the docs too.

I reverted xaxis.tickPlacement: between as this seems to be the easiest fix for now.

@junedchhipa Looks like this is still an issue with datetimes that include month. Saw in the docs that tickPlacement does not affect the datetime. Any tricks to get around it cutting that last label on the right?

https://codesandbox.io/s/o2j3znx0q

Re-opening this if datetime labels still have an issue with the last label.

If you use a custom formatter function, the labels will still break out of the rendering area.

https://codesandbox.io/s/vue-basic-example-2dw9c

Hello, the issue persists, but in my case on the first value. 'between' option works well for categorical variables but as the doc says not for numerical.
Would be very grateful to fix this.

Still seeing the same issue with 3.8.5

Screenshot 2019-09-02 17 10 41

I had the same problem for datalabels, Changing CSS for labels helped me to solve it
.apexcharts-data-labels{ display:contents !important; }

break labels chart

when I use "min: new Date('01-01-2019').getTime()" in xaxis to display chart from the start of the year, first column and label cropped.

apexcharts 3.10.1
ng-apexcharts 1.1.1

Everyone please do the following. It should work

xaxis: { tickPlacement: 'between', }

This should solve the problem.

I am using
"apexcharts": "^3.10.1",
"vue-apexcharts": "^1.5.1",

Same problem here, the last date on the bottom corner in the right is cropped =(

My options for xaxis are

{
  xaxis: {
      title: {
        text: xaxisTitle,
        style: {
          fontSize: 20,
          color: '#ffffff'
        }
      },
      labels: {
        formatter: value => {
          return moment(new Date(value)).format('MM-YYYY')
        },
        style: {
          fontSize: 20
        }
      },
      tickAmount: 5,
      tickPlacement: 'between'
  }
}

image

I'm using the react-apexcharts on version 1.3.5"

Still having that issue with datetime on version1.3.16

Guys, after studying this issue, it happened to me that when I converted the datetimes to milliseconds, somehow the program interpreted those datetimes in GMT timezone, and then converted it to my timezone (UTC -3). Consequently, I always got the date of the last day which led me to think that the last date was being cropped.

My solution was to simply add up 3 hours (or 3*3.6e6 milliseconds) to my timestamps.

This did the trick for me:

xaxis: { tickPlacement: 'on', }

Screen Shot 2020-04-20 at 13 43 26

Still an issue and no fix at the moment. Using a datetime type and moment.utc(item.created_at).valueOf().

This issue should not be closed. I am seeing this bug on fresh installation of latest apex chart 3.20.0 and vue-apexcharts 1.6.0, with datetime type x data on a line chart. I used the workaround

.apexcharts-xaxis-label:nth-last-child(2) {
  transform: translateX(-20px)
}

Had to add an entire day to each of my datetime x-axis entries just to get the last month to show up. January still doesn't show.

moment.utc(item.date, 'Y-MM', true).add(1, 'day').valueOf(),

Using a numeric x-axis shows January and December double. Tried to tweak it, but either it shows them double or not at all.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rudeayelo picture rudeayelo  路  3Comments

maasha picture maasha  路  3Comments

artfulrobot picture artfulrobot  路  3Comments

piyushSinghalDemo picture piyushSinghalDemo  路  3Comments

felixalguzman picture felixalguzman  路  3Comments