How to change tick's text with ordinal axis

浪子不回头ぞ 提交于 2019-12-10 23:29:44

问题


I have chart with next properties:

barChart
       .width(width)
       .height(height)
       .dimension(dim)
       .group(group)
       .x(d3.scale.ordinal())
       .xUnits(dc.units.ordinal)

My axis tick looks like "ZZxBob", "PxBob"

How to use split function by 'x' to each tick?


回答1:


The axes are generated entirely by D3.

You can use chart.xAxis() to retrieve the x axis object, and then axis.tickFormat() to change the way it's displayed.

So, e.g. to display the part before x:

barChart.xAxis()
    .tickFormat(function(l) { return l.split('x')[0]; })


来源:https://stackoverflow.com/questions/44526943/how-to-change-ticks-text-with-ordinal-axis

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!