I have change the code as below.. But still getting the same error
var dataTable = new google.visualization.DataTable();
dataTable.addColumn('string','stock');
dataTable.addColumn('date','Time');
dataTable.addColumn('number','price');
var json=$.parseJSON(jsonData);
var formatDate = new google.visualization.DateFormat({
pattern: 'yyyy-MM-dd hh:mm:ss' //'yyyy-MM-dd hh:mm:ss'
});
json.forEach(function (row) {
var rowDate = new Date(row.Time);
document.write(row.Time + " " + formatDate.formatValue(rowDate));
dataTable.addRow([
row.stock,
//formatDate.formatValue(rowDate),
row.Time,
row.price
]);
});
On Friday, May 11, 2018 at 11:20:31 AM UTC+5:30, Dragan Mestrovik wrote:
>
> Hi,
>
> When i tried to show the data in a chart, i am getting the below error.
> Can anyone help me why it is not converting the date "*2018-04-01
> 00:00:53*"?
>
> *Type mismatch. Value 2018-04-01 00:00:53 does not match type date in
> column index*
>
> And my code is
>
> var dataTable = new google.visualization.DataTable();
> dataTable.addColumn('string','stock');
> dataTable.addColumn('date','Time');
> dataTable.addColumn('number','price');
>
>
> var json=$.parseJSON( jsonData);
>
> for (var i=0;i<json.length;i++) {
> delete json[i].id;
> delete json[i].LastTradePrice;
> delete json[i].Min24hrs;
> delete json[i].LowestAsk;
> delete json[i].Max24hrs;
> delete json[i].HighestBid;
> var row = [];
> for (var item in json[i]) {
> row.push(json[i][item]);
> }
> dataTable.addRow(row);
> }
>
> var data =google.visualization.Table(dataTable,true);
> var chart = new
> google.visualization.CandlestickChart(document.getElementById('chart'));
> chart.draw(data, {width: 400, height: 240});
>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-visualization-api/84696c35-cb8d-49e3-8ad0-1518eb5d6faa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.