d3.json('http://www.mocky.io/v2/57d14d2f100000cd19208e19', function (error, historicalBarChart) {
(function() {
nv.addGraph(function() {
var chart = nv.models.discreteBarChart()
.x(function(d) { return d.label })
.y(function(d) { return d.value })
.staggerLabels(true)
//.staggerLabels(historicalBarChart[0].values.length > 8)
.showValues(true)
.duration(250)
.height(300)
.width(400)
;
var filtered1=historicalBarChart[0].values.filter(function(d) { return d.value > 15;});
console.log(filtered1); // getting filtered json here
d3.select('#chart2 svg')
.datum(filtered1) // doesn't render chart for filtered json
.transition().duration(500)
.call(chart);
nv.utils.windowResize(chart.update);
return chart;
});
})();
});
を使用してnvd3チャートを描く私は、APIデータ内の15以上の値のデータをフィルタリングし、データがフィルタリング取得されていないとチャートがあるchart.Butを描画しようとしていますデータが利用できないために表示されません。データをフィルタリングしてnvd3グラフを表示するにはどうすればよいですか?前もって感謝します !!フィルタJSONデータおよびフィルタリングされたデータ
JSONが..濾過し、チャートのレンダリングが、全体のフィルタリングされていないJSONと... –
はあなたが投稿できますあなたの変更されたコードはどうですか? – codename44
あなたの推薦に従ってコードを更新しました... jsonがフィルタリングされてもチャートがレンダリングされません...私はおそらく、jsonがフィルタリングの後に返される形式のために考えています...また、コンソール "Uncaught TypeError:未定義のプロパティ 'length'を読み取ることができません" ... –