如何在d3.js轴中增加刻度标签宽度 [英] How to increase tick label width in d3.js axis

查看:127
本文介绍了如何在d3.js轴中增加刻度标签宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该更改哪个参数以修改此示例中的刻度标签宽度?我有很多数字,但很少有数字被剪掉...

Which parameter should I change to modify the tick label width in this example? I have big numbers and few digits are cut...

推荐答案

标签的空间由图的左边缘确定:

The space for the labels is determined by the left margin of the plot:

var margin = {top: 20, right: 20, bottom: 30, left: 40},

要为其提供更多空间,您需要做的就是增加数字,例如

All you need to do to give it more space is increase the number, e.g.

var margin = {top: 20, right: 20, bottom: 30, left: 100},

完整演示此处.您可能还需要考虑格式化标签,以免占用过多空间,请参见 .tickFormat()函数.

Complete demo here. You may also want to consider formatting your labels differently so that they don't use up as much space, see the .tickFormat() function.

这篇关于如何在d3.js轴中增加刻度标签宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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