1
ダイアグラムを機能させることができません。私は、グラフのデータを構築するdygraphsラベルの数と配列の列数の不一致
data = [
{
"DATA": "2016-01-22",
"TOTAL": [
"7",
"4",
"20",
"0"
]
},
{
"DATA": "2016-01-25",
"TOTAL": [
"3",
"2",
"10",
"0"
]
},
{
"DATA": "2016-01-26",
"TOTAL": [
"1",
"1",
"4",
"0"
]
},
{
"DATA": "2016-01-27",
"TOTAL": [
"2",
"1",
"2",
"0"
]
},
{
"DATA": "2016-02-02",
"TOTAL": [
"1",
"1",
"1",
"0"
]
},
{
"DATA": "2016-02-10",
"TOTAL": [
"1",
"1",
"3",
"0"
]
}
]
として:
私がどのように見えるPHPから移入配列持ち
data.forEach(function(item) {
var adata = item.DATA;
var atotal = item.TOTAL;
graphstr1 += '[new Date("' + adata + '"),' + atotal + '],';
});
graphstr1 = graphstr1.slice(0, -1);
console.log(graphstr1);
はコンソールで探している、データが必要ですフォーマットが、私はいつもQUEの質問のタイトル
Dygraphコードにエラーが表示されます。
g = new Dygraph(
document.getElementById("graphdiv"), [
graphstr1,
/*[new Date("2016-01-22"), 7, 4, 20, 0],
[new Date("2016-01-25"), 3, 2, 10, 0],
[new Date("2016-01-26"), 1, 1, 4, 0],
[new Date("2016-01-27"), 2, 1, 2, 0],
[new Date("2016-02-02"), 1, 1, 1, 0],
[new Date("2016-02-10"), 1, 1, 3, 0]*/
], {
labels: ["x", "Registados", "Grávidas", "Com Filhos", "Sem Filhos"]
}
);
はあなたのコードを試してみましたが、まだエラーを取得:配列 – mjpramos
@mjpramosのラベル(X、Registados、Grávidas、コムFILHOS、セムFILHOS)の数と列の数との間の不一致、それを私のために右に見えます。 –
ダーン!それは行為の中で! gy = new Dygraph(document.getElementById( "graphdiv")の代わりにgraphstr1(document_getElementById( "graphdiv")、graphstr1 ...)を使用していました。 – mjpramos