0

I am trying to create a timeline chart using Apex.js library. Even after passing dates in the required format, it throws an error:

Uncaught (in promise)

Error: Please provide [Start, End] values in valid format. Read more https://apexcharts.com/docs/series/#rangecharts

Here's what my dateArr looks like.

let dateArr = [];

let startDate = ["01-12-2021", "10-10-2021", "01-12-2021", "20-09-2021", "20-09-2021", "27-09-2021"];
let endDate = ["31-12-2021", "30-11-2021", "31-12-2021", "31-12-2021", "24-09-2021", "15-10-2021"]
let categories = ["Community Release / Review", "Development", "Documentation", "Gathering Visualizations", "Overview", "Training"]

for (let i = 0; i < categories.length; i++) {
  dateArr.push([startDate[i], endDate[i]]);
}

console.log(dateArr)
James Z
  • 12,209
  • 10
  • 24
  • 44
Prashant
  • 9
  • 3
  • 1
    Your strings aren't in the [format shown in the docs](https://apexcharts.com/docs/series/#:~:text=3.2)-,Date%20strings,-series%3A%20%5B%7B%0A%20%20data%3A%20%5B%7B%20x). The note in the docs says *"The DateTime String which you provide should return true when parsed through JavaScript’s Date.parse() function"* which is silly (`Date.parse` never returns `true`) but suggests that they expect what you provide to be parsed by `Date.parse`. What you're providing is not reliably parsed by `Date.parse`. – T.J. Crowder Oct 18 '21 at 07:32
  • Thanks @T.J.Crowder That's absolutely true. After further debugging, I noticed that the expected date format is mm-dd-yyyy ONLY. – Prashant Oct 19 '21 at 05:44
  • That's odd, that's not what the docs say. And beware that `mm-dd-yyyy` is **not** consistently parsed across JavaScript engines. (`mm/dd/yyyy` is despite not being in the spec, but not `mm-dd-yyyy`.) They must be parsing it themselves if they won't accept things like `yyyy-mm-dd` for instance (the standard format for date-only, although sadly it took a bit to nail down what timezone that used, details in my answer [here](https://stackoverflow.com/a/14924025/157247)). – T.J. Crowder Oct 19 '21 at 08:28

0 Answers0