0
我該怎麼辦根據d.Status!==""
下面分別d屬於數據(sortedFeatures)如何根據其數據的符號添加到組
feats = cont.selectAll('feats')
.data(sortedFeatures)
.enter()
.append('g')
.attr('transform', function(d, i) {
d['y'] = (fontsize * i);
d['x'] = self.x_scale(d.start);
return 'translate(' + self.x_scale(d.start) + ',' + fontsize * i + ')';
}).attr('type', 'featureGroup');
polygonLastDelivery = feats.append('g');
polygonLastDelivery.append("path")
.attr("class", "point")
.attr("d", d3.svg.symbol().type("cross"))//I don't want to add this symbol if d.Status==="" can I make a function out of this?
.attr("transform", function(d) { return "translate(" + 15 + "," + 22 + ")"; });
這就是我想要一個符號添加到新創建的組「polygonLastDelivery」取決於 .data(sortedFeatures)每個是否包含狀態文本或者是否爲空。你怎麼解決這個問題?
我嘗試上述whitout成功以下
.attr("d", function(d) { return d3.svg.symbol().type("cross");})
根據「狀態」屬性篩選您的選擇,然後將符號添加到過濾的選擇。 – 2014-11-22 14:57:16