DEMOErhalten konstanten Abstand von Zecken Wert in d3.scaleTime()
Ich brauche einen konstanten Abstand von Zecken Wert zwischen jedem beliebigen Datum zu erhalten, mit d3.scaleTime() und Grundstück in einer Achse.
Aber
timeScale.nice(intervalValue);
//or
axisXScale.tickValues(timeScale.ticks(10));
hilft nicht, ich bin immer wieder zufällige Anzahl der Ticks Werte zu bekommen.
Wie pro D3 Dokumentation
# continuous.ticks([count])
Returns approximately count representative values from the scale’s domain. If count is not specified, it defaults to 10.
The returned tick values are uniformly spaced, have human-readable values (such as multiples of powers of 10), and are guaranteed to be within the extent of the domain.
Ticks are often used to display reference lines, or tick marks, in conjunction with the visualized data.
The specified count is only a hint; the scale may return more or fewer values depending on the domain.
So ist es eine Möglichkeit, wir eine konstante Zahl bekommen, statt Annäherung
Aber wie wir eine konsistente Anzahl zwischen zwei Terminen mit 'd3.timeMonth' – Sarath
bekommen können, können Sie es gerne verwenden: d3.axisBottom (Zeitskala) .tickSize (0) .ticks (d3.timeMonth.every (1)) –
Wenn ich ein einjähriges Intervall habe, gibt es 12 und wenn sein 6-Monats-Intervall 6 ist, Was ich will, ist in allen Fällen eine konstante Zahl – Sarath