0
Ich möchte JSON in ChartJS verwenden. Im ersten Beispiel verwenden ichJSON Daten in Javascript
[ "0", "76", "32", "88"]
und alles sieht gut aus.
Problem ist im zweiten Beispiel, wenn I JSON Daten verwendet werden soll, wie:
var json = [{ "wartość": "0"}, { "wartość": "76"}, {“ wartosc ":" 32 "}, {" wartosc ":" 88 "}];
In Variable chartjsData möchte ich Daten wie ["0", "76", "32", "88"] aber es funktioniert nicht.
var json =[{"wartosc":"0"},{"wartosc":"76"},{"wartosc":"32"},{"wartosc":"88"}];
var chartjsData = [];
for (var i = 0; i < json.lenght; i++) {
chartjsData.push (json[i].wartosc);
}
var areaChartData = {
labels: ["j","j","j","j"],
datasets: [
{
label: "Electronics",
fillColor: "rgba(210, 214, 222, 1)",
strokeColor: "rgba(210, 214, 222, 1)",
pointColor: "rgba(210, 214, 222, 1)",
pointStrokeColor: "#c1c7d1",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(220,220,220,1)",
data: ["0","76","32","88"]
},
{
label: "Digital Goods",
fillColor: "rgba(60,141,188,0.9)",
strokeColor: "rgba(60,141,188,0.8)",
pointColor: "#3b8bba",
pointStrokeColor: "rgba(60,141,188,1)",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(60,141,188,1)",
data: chartjsData
}
]
};