问题
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