在时间轴的刻度标签中改变字体大小 [英] Vary font size in tick labels of time axis

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

问题描述

我基于常规时间轴绘制时间序列数据。现在,我使用默认的多刻度刻度格式,所以我在X轴上看到与AM / PM小时相结合的日期。

I'm plotting time series data based on a regular time axis. For now, I use the default "multi-scale" tick format, so I see dates combined with AM/PM hours on the X axis.

现在:以更大的字体大小显示日期,使它们从小时刻度中脱颖而出?所有的ticks似乎都有相同的tickCSS类,所以我不能使用CSS区分它们...

Now: how can I show the dates in a bigger font size, to make them stand out from the hour ticks? All ticks seem to have the same "tick" CSS class, so I can't differentiate between them using CSS...

任何建议是赞赏。

Any suggestion is appreciated.

推荐答案

D3不提供任何区别生成的不同类型的记号,但您可以检查在设置中生成标签时使用的条件风格。代码看起来像这样。

D3 doesn't provide anything to distinguish between the different types of ticks generated, but you can check the condition used in generating the labels in setting the styles as well. The code would look something like this.

d3.selectAll(".tick > text")
  .style("font-size", function(d) { return d.getHours() == 0 ? 32 : 24; });

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

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