javascript - D3js data selection -


i trying use fiddle filter out data following thread

d3 js data filtering

my fiddle

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

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -