Gibt es eine Möglichkeit, Datumswerte von JSON in Google Visualization API abzurufen? Hier ist die snipplet für playgroundbitte den Code unten in esRückgabe eines Datumswerts von JSON an Google Visualization API
kopieren Wenn Sie den Code ausführen Sie nichts in Folge haben wird. Sie sollten die Anführungszeichen aus dem mit Kommentar markierten Datumswert entfernen, um das Ergebnis zu erhalten.
function drawVisualization() {
var JSONObject = {
cols:
[
{id: 'header1', label: 'Header1', type: 'string'},
{id: 'header2', label: 'Header2', type: 'date'}
],
rows:
[
{
c:
[
{v: 'Value1'},
{v: "new Date(2010, 3, 28)"} // <= This is the format I receive from WebService
]
},
{
c:
[
{v: 'Value2'},
{v: new Date(2010, 3, 28)} // <=This is the format Google API accepts
]
}
]
};
var data = new google.visualization.DataTable(JSONObject, 0.5);
visualization = new google.visualization.Table(document.getElementById('table'));
visualization.draw(data, {'allowHtml': true});
}
Geck ich das gleiche Problem! –
Ich weiß, das ist eine ziemlich alte Frage, aber ich habe das gleiche Problem und Sie könnten helfen. Dies ist mein json '[[" (Datum (2015,6,1) ", 9,218,0], [" Datum (2015,7,1) ", 10,497.5], [" Datum (2015,8,1) ", 13,317.5] , ["Datum (2015,9,1)", 29,1572,0], ["Datum (2015,10,1)", 34,480.0], ["Datum (2015,11,1)", 20.387,0], [" Datum (2016,0,1) ", 34.836,0], [" Datum (2016,1,1) ", 29.957,5], [" Datum (2016,2,1) ", 2.1250,0], [" Datum (2016 , 3,1) ", 2.793,5], [" Datum (2016,10,1) ", 3.801,0], [" Datum (2016,11,1) ", 2,756,5], [" Datum (2017,1,1)] ", 2.410.0]]' und ich bekomme Uncaught Error: Type mismatch. Das Valutadatum (2015, 6, 1) entspricht nicht dem Typ Datum im Spaltenindex 0. –