Adding a specific tick to the D3.js axis

I created the c axis d3.svg.axisand the timeline, and I am pleased with the ticks created by the tick generator. However, I would like to make sure that a certain value is always noted. For example, if the generator produces the following dates

2000-1-1, 2001-1-1, 2002-1-1, 2003-1-1

I may need to show the axis

2000-1-1, 2000-7-21 , 2001-1-1, 2002-1-1, 2003-1-1

How to get an array of ticks made by a tag generator so that I can add my value and pass it to a function tickValues?

I could create a second axis, stylize it to remove the domain path and pass any additional dates to these functions tickValues, but this seems a bit inconvenient.

Or am I going to do it wrong?

thank

+4
1

, ticks() , , :

ticks = myScale.ticks();

// :

ticks.push(some_new_value):

tickValues

myAxis.tickValues(ticks);

, , SVG, .

+10

Source: https://habr.com/ru/post/1543393/


All Articles