I have a data array like the following:
mydata = [ {
"title": "key1",
"description": "some description 1",
"visible": "1",
},
{
"title": "key2",
"description": "some description 2",
"visible": "0",
},
{
"title": "key3",
"description": "some description 3",
"visible": "1",
}
]
...and with the following code:
var chart = svg.selectAll("g.chart")
.data(mydata, function(i, d)
{
return d;
})
.enter()
.append("svg:g")
.attr("class", "chart")
.attr("style", "position:fixed");
With the following code, how can I skip the item with "visible" = 0?
Basically, show everything with visibility = 1?
Thanks
You can use .filter():
.data(mydata.filter(function(d) { return d.visible == "1"; }))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With