我有包含下一个属性的图表:
barChart
.width(width)
.height(height)
.dimension(dim)
.group(group)
.x(d3.scale.ordinal())
.xUnits(dc.units.ordinal)
我的轴刻度看起来像“ZZxBob”、“PxBob”
如何对每个刻度使用“x”分割功能?
轴完全由 D3 生成。
您可以使用chart.xAxis() http://dc-js.github.io/dc.js/docs/html/dc.coordinateGridMixin.html#xAxis__anchor检索 x 轴对象,然后axis.tickFormat() https://github.com/d3/d3-3.x-api-reference/blob/master/SVG-Axes.md#tickFormat更改其显示方式。
所以,例如显示 x 之前的部分:
barChart.xAxis()
.tickFormat(function(l) { return l.split('x')[0]; })
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)