javascript - D3js data selection -
i trying use fiddle filter out data following thread
my fiddle
i trying this
var svg = d3.select('#reportcontent_reportcontent svg') .data(data).filter(function (v) { return data.product === "lending"; }) .attr("class", "bullet") .attr("width", width + margin.left + margin.right) .attr("height", height + margin.top + margin.bottom) .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")") .call(chart);
my data looks
var data = [{ "monthyearshortname": "2014-09-13t00:00:00", "product": "fee based", "actual": [1002], "forecast": [1200], "target": [1400] }, { "monthyearshortname": "2014-09-13t00:00:00", "product": "lending", "actual": [8146873.33], "forecast": [7220309.99], "target": [7220309.995] }];
i wanted pick 'lending', example trying doesnt work. tell me doing wrong.
thanks.
here fiddle correct syntax , data.
.data(data.filter(function(d) {return d.product === 'lending';}))
you can change filtering criterium between 'fee based' , 'lending' see @ work.
Comments
Post a Comment