How to change tick's text with ordinal axis

2019-07-24 10:31发布

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?

标签: dc.js
1条回答
一纸荒年 Trace。
2楼-- · 2019-07-24 10:46

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]; })
查看更多
登录 后发表回答