3
我正在使用Mike Bostock的彩虹蟲作爲我的項目的一部分。 https://bl.ocks.org/mbostock/4165404更改彩虹蟲的顏色
我試圖改變蠕蟲的顏色,因爲它會在項目代表風速。着色描述了這個功能:
var path = svg.selectAll("path")
.data(quad(points))
.enter().append("path")
.style("fill", function(d) { return d3.hsl(z(d[1].value), 1, .5); })
.style("stroke", "#000");
如果我用「顏色」替換函數(d),蠕蟲將會是單色的。 我怎樣才能讓蠕蟲部分顏色爲紅色 - >白色 - >紅色 - >白色 - >紅色 - >白色等等?