Hashim
Hashim

Reputation: 11

Google Charts "Type Mismatch" Error With Date

this is my first question!

I'm trying to make a line graph with the Google Charts API and I've run into a very strange error that I can't seem to solve.

I'm getting an error that the Date I passed to the chart is not a valid date format.

The variable that I'm passing to my Chart API looks like this:

rows[x] = [data[x].date, data[x].price, data[x].trendVal];

In this instance, the value of data[x].date looks something like this:

2013-01-02T00:00:00.000Z

The error I see in my Chrome console is:

Uncaught Error: Type mismatch. Value 2013-01-02T00:00:00.000Z does not match type date in column index 0
at gvjs_fn (jsapi_compiled_default_module.js:75)
at gvjs_Iba (jsapi_compiled_default_module.js:95)  ...

What am I doing wrong? Any help would be much appreciated.

Upvotes: 1

Views: 1171

Answers (1)

WhiteHat
WhiteHat

Reputation: 61222

try creating a date from the value...

rows[x] = [new Date(data[x].date), data[x].price, data[x].trendVal];

Upvotes: 1

Related Questions