Vary font size in tick labels of time axis

断了今生、忘了曾经 提交于 2019-12-10 21:11:10

问题


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.

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.


回答1:


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; });


来源:https://stackoverflow.com/questions/19680997/vary-font-size-in-tick-labels-of-time-axis

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!