みんな!まず第一に、私はこの種のものが非常にくだらないことを知っていますが、それが私の目標の達成を視覚化する方法です.
取り決めは次のとおりです。配列を含む JSon オブジェクトがありますが、残念ながら、1 つの JSon オブジェクトのリストを反復処理してから、前に説明した配列を反復処理する必要があります。JSON オブジェクトは次のようになります (ポルトガル語ですが、理解できるはずです)。
{"produtos":[{"Key":"DERIVADOS DE FERRO","Value":217816909},{"Key":"MADEIRAS, SUAS MANUFATURAS E MOBILIÁRIO MÉDICO CIRÚRGICO","Value":117812290},{"キー":"CELULOSE, PAPEL E SUAS OBRAS","Value":100086937},{"Key":"CARNE SUÍNA","Value":81738783},{"Key":"CARNE BOVINA","Value":74894768 },{"Key":"CARNE DE AVES","Value":65292433},{"Key":"Outros","Value":444520811}],"ano":2005,"tipo":1}
Produtos は先ほど説明した配列で、他に重要な値が 2 つあります。ano (年) と tipo (型) です。私のコードは次のようになります。
jQuery.getJSON("/webportos/Porto/GraficoComercio?id=" + iddoporto.className + "&ano=2005", null, function (items) {
jQuery.each(items, function (itemNo, item) {
jQuery.each(item.produtos, function (dicNo, dic) {
options.series.push({ name: dic.Key, data: dic.Value});
options.title.text = "Comércio - "+item.ano;
options.yAxis.title.text = "Exportação";
options.tooltip.formatter = function () {
return '<b><u>' + this.series.name + '</u></b><br/><b>' + this.x + '</b>: ' + this.y + ' ';
}
});
});
chart = new Highcharts.Chart(options);
});
This piece of code makes Chrome javascript console to display:
ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js:32 Uncaught TypeError: Cannot read property 'length' of undefined
皆さん、私を助けてくれませんか?