2

I'm using the google-chart component and want to use a DateTime in one of my columns. I can't figure out how to pass the value in though. My code looks like this:

<google-chart
    type='line'
    options='{"legend": "none"}'
    cols='[{"label":"Dates", "type": "datetime"}, {"label":"Numbers", "type": "number"}]'
    rows='[["2012-03-19T07:22:00Z", 73628]]'>
</google-chart>

The "DateTime" in the code above is my latest try, which also doesn't work. I've tried multiple different versions (e.g. "2012-04-21T18:25:43-05:00", DateTime("Mon, 25 Dec 1995 13:30:00 GMT"),...).

All failed with the following error message:

Error: Type mismatch. Value 2012-03-19T07:22:00Z does not match type datetime in column index 0

I would highly appreciate if someone could tell me how to pass in a value.

Dennis Hein
  • 257
  • 1
  • 12

1 Answers1

0

Live example, as Plunk or JSbin, would help mostly to answer the question. But, generally you need to convert the value to date type:

  ...
  rows='[[rows_date, 73628]]'>
  ...

 <script>
    Polymer({

       rows_date: new Date(),
       //or
       domReady: function(){
         this.rows_date = new Date(this.rows_date);
       },
    });
 </script>

Values in attributes are always strings. If you want Polymer to convert an attribute string to another type, you have to hint the type you want.

Goce Ribeski
  • 1,352
  • 13
  • 30