Ame*_*aBR 18
由d3轴函数创建的刻度具有与其绑定的刻度值作为数据对象.绘制轴后,您可以重新选择刻度并根据其数据对其进行操作.
例如,您可以筛选选择以仅查找具有特定值的刻度.然后,您可以应用与任何其他d3选择相同的样式或类.
d3.selectAll('g.tick')
.filter(function(d){ return d==50;} )
//only ticks that returned true for the filter will be included
//in the rest of the method calls:
.select('line') //grab the tick line
.attr('class', 'quadrantBorder') //style with a custom class and CSS
.style('stroke-width', 5); //or style directly with attributes or inline styles
Run Code Online (Sandbox Code Playgroud)
更多解释和另一个例子,在属性调用中使用基于数据的函数而不是使用过滤器:https:
//stackoverflow.com/a/21583985/3128209