如何使用序数轴更改刻度的文本 [英] How to change tick's text with ordinal axis

查看:77
本文介绍了如何使用序数轴更改刻度的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的图表具有以下属性:

I have chart with next properties:

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

我的轴刻度看起来像 ZZxBob, PxBob

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

如何对每个刻度线使用'x'分割功能?

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

推荐答案

轴完全由D3生成。

您可以使用 chart.xAxis() 来检索x轴对象,然后 axis.tickFormat() 更改其显示方式。

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

因此,例如显示x之前的部分:

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

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

这篇关于如何使用序数轴更改刻度的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆