chartjs / chartjs/chartjs-adapter-moment

[BUG] Deprecation Warning - from moment.js when using time axes

Open
#23 8 comments 5 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
37
Forks
24
PR merge metrics
No merged PRs in 30d

Description

## Expected Behavior

## Current Behavior
```error
Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.
Arguments:
[0] _isAMomentObject: true, _isUTC: false, _useUTC: false, _l: undefined, _i: 2018.01.01, _f: undefined, _strict: undefined, _locale: [object Object]
Error
at Function.createFromInputFallback (http://127.0.0.1:8000/static/documerge/node_modules/moment/moment.js?v=1523389320944:320:98)
at configFromString (http://127.0.0.1:8000/static/documerge/node_modules/moment/moment.js?v=1523389320944:2368:15)
at configFromInput (http://127.0.0.1:8000/static/documerge/node_modules/moment/moment.js?v=1523389320944:2594:13)
at prepareConfig (http://127.0.0.1:8000/static/documerge/node_modules/moment/moment.js?v=1523389320944:2577:13)
at createFromConfig (http://127.0.0.1:8000/static/documerge/node_modules/moment/moment.js?v=1523389320944:2544:44)
at createLocalOrUTC (http://127.0.0.1:8000/static/documerge/node_modules/moment/moment.js?v=1523389320944:2631:16)
at createLocal (http://127.0.0.1:8000/static/documerge/node_modules/moment/moment.js?v=1523389320944:2635:16)
at hooks (http://127.0.0.1:8000/static/documerge/node_modules/moment/moment.js?v=1523389320944:12:29)
at momentify (http://127.0.0.1:8000/static/documerge/node_modules/chart.js/dist/Chart.js?v=1523389320944:13795:11)
at parse (http://127.0.0.1:8000/static/documerge/node_modules/chart.js/dist/Chart.js?v=1523389320944:13817:14)
warn @ moment.js?v=1523389320944:293
(anonymous) @ moment.js?v=1523389320944:320
configFromString @ moment.js?v=1523389320944:2368
configFromInput @ moment.js?v=1523389320944:2594
prepareConfig @ moment.js?v=1523389320944:2577
createFromConfig @ moment.js?v=1523389320944:2544
createLocalOrUTC @ moment.js?v=1523389320944:2631
createLocal @ moment.js?v=1523389320944:2635
hooks @ moment.js?v=1523389320944:12
momentify @ Chart.js?v=1523389320944:13795
parse @ Chart.js?v=1523389320944:13817
determineDataLimits @ Chart.js?v=1523389320944:14149
update @ Chart.js?v=1523389320944:7230
update @ Chart.js?v=1523389320944:14109
getMinimumBoxSize @ Chart.js?v=1523389320944:6416
each @ Chart.js?v=1523389320944:9899
update @ Chart.js?v=1523389320944:6430
updateLayout @ Chart.js?v=1523389320944:4259
update @ Chart.js?v=1523389320944:4214
construct @ Chart.js?v=1523389320944:3944
Chart @ Chart.js?v=1523389320944:6215
```

![image](https://user-images.githubusercontent.com/14252381/38584187-276f3b6a-3d33-11e8-9bef-be64915589d7.png)

## Possible Solution
Moment.js might deprecate the functionality. Unless provided date format along with date. like `moment(value, format)` in #13795 form the above screenshot

## Steps to Reproduce (for bugs)

1. Configure to time axis
```js
{
type: "line",
data: {
// labels: ["Used", "Remaining"],
datasets: [{
label: 'Test Merges',
xAxisID: "time",
fill: true,
lineTension: 0,
data: [
{x: '01-01-2018', y:10},
{x: '02-01-2018', y:5},
{x: '02-05-2018', y:15}
]
}]
},
config: {
scales: {
xAxes: [{
id: 'time',
type: 'time',
time: {
tooltipFormat: "DD MMMM, YYYY"
}
}]
}
};
}
}
```

## Environment

* Chart.js version: "^2.7.2",
* Chrome 65.0.3325.181

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the time-axis reproduction and the momentify and parse entry points shown in the Chart.js stack trace. Check how the example date values are handled with Chart.js 2.7.2 and moment.js, then verify the time axis works without the reported deprecation warning in Chrome.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data-visualization, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.