D3:更改轴标签的字体大小 [英] D3: change font size of axis labels

查看:112
本文介绍了D3:更改轴标签的字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为使用D3创建的时间轴的标签指定字体大小.我已经尝试使用此答案.rel ="noreferrer">这把小提琴,但是它似乎什么也没做.我也尝试过

I want to specify a font size for the labels of a time axis created with D3. I've tried following this answer with this fiddle, but it doesn't seem to do anything. I've also tried

d3.selectAll(".xAxis>.tick>text")
  .each(function(d, i){
    d3.select(this).style("font-size",30);
  });

无济于事.没那么难...

to no avail. It can't be that hard...

推荐答案

原来,无单位编号是从技术上讲不是有效的CSS字体大小说明符,并且是否取决于它取决于浏览器.因此,使用

It turns out that a unitless number is technically not a valid CSS font size specifier and that it may depend on the browser whether it is ignored or not. Therefore, use

d3.select(this).style("font-size","30px");

代替

d3.select(this).style("font-size",30);

这篇关于D3:更改轴标签的字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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