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

Wrong date for x-axis if dataset begins from one last date of month. #3466

Closed
flxb-awm opened this issue Oct 31, 2022 · 4 comments
Closed

Wrong date for x-axis if dataset begins from one last date of month. #3466

flxb-awm opened this issue Oct 31, 2022 · 4 comments
Labels
bug Something isn't working verified

Comments

@flxb-awm
Copy link

flxb-awm commented Oct 31, 2022

Description

there is Graph with datetime data:

{
  "legend": {
    "show": false
  },
  "series": [
    {
      "name": "Delivered quantity",
      "data": [
        {
          "x": "2022-10-31",
          "y": 7.5
        },
        {
          "x": "2022-11-01",
          "y": 0
        },
        {
          "x": "2022-11-02",
          "y": 0
        },
        {
          "x": "2022-11-03",
          "y": 0
        },
        {
          "x": "2022-11-04",
          "y": 0
        },
        {
          "x": "2022-11-05",
          "y": 0
        },
        {
          "x": "2022-11-06",
          "y": 0
        }
       
    }  
  ],
  "chart": {
    "zoom": {
      "enabled": false
    },
    "height": 332,
    "type": "bar",
    "animations": {},
    "toolbar": {
      "show": false
    },
    "stacked": true
  },
  "xaxis": {
    "type": "datetime",
    "labels": {
       format: 'ddd'
    },
    "min": 1667174400000,  
  },
  "yaxis": {
    "labels": {},
    "tooltip": {
      "enabled": false
    }
  },
  "tooltype": {
    "x": {}
  }
}

set of data begin from 2022-10-31 and finished for 2022-11-06 (one weeks)
and

Steps to Reproduce

  1. run the graph with the options

Expected Behavior

there is graph with one column and x axis with name of weekdays abbreviation names begin from Monday
Mon Tue Wed Thu Fri Sat San

Actual Behavior

there is graph with one column and x axis with name of weekdays abbreviation names begin from Saturday
Sat Tue Wed Thu Fri Sat San

Screenshots

Снимок экрана 2022-10-31 в 16 12 42

Reproduction Link

https://codepen.io/F-Tulpan/pen/poKjBGR

@flxb-awm flxb-awm added the bug Something isn't working label Oct 31, 2022
@flxb-awm
Copy link
Author

flxb-awm commented Oct 31, 2022

if change the formatLabel for x-axis to 'dd/MM'

Снимок экрана 2022-10-31 в 16 18 33

it looks like the first date is spoiled.

https://codepen.io/F-Tulpan/pen/JjZYeMK

and it looks like the issue happens if only first date of set belong end day of prev month.

Снимок экрана 2022-10-31 в 16 30 15

https://codepen.io/F-Tulpan/pen/gOKayJY

@flxb-awm flxb-awm changed the title Wrong date for x-axis if month begin from tuesday Wrong date for x-axis if dataset begins from one last date of month. Oct 31, 2022
@jhemak
Copy link

jhemak commented Mar 31, 2024

Did you ever figure out a fix or workaround for this?

@nara1111
Copy link

Hey, this bug is still ALIVE!!!!

@salil-01
Copy link

salil-01 commented Dec 9, 2024

@junedchhipa any update on this issue, this bug still persists..

  • As a workaround - instead of giving datetime as a type on xAxis of bar charts, give the type numeric with tickAmounts and use formatter in labels to format the datetime.
// example of formatting in locale 
formatter: function (value) {
  const date = new Date(value);
  const formatter = new Intl.DateTimeFormat("en", {
    day: "2-digit",
    month: "short",
  });
  return formatter.format(date);
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working verified
Projects
None yet
Development

No branches or pull requests

5 participants