marioosh
marioosh

Reputation: 28556

d3.js - Generate ticks only to max value

How to set tick max value that will be generated (visible) on an axis ? I have multi-line chart with multiple y axis. One of line chart has max value in half of axis y. How to prevent generating ticks above this max value ? Now i'm using .tickValues(domain);, but this generate only min and max.

enter image description here

Upvotes: 1

Views: 2781

Answers (1)

Christopher Hackett
Christopher Hackett

Reputation: 6192

Assuming domain is an array of the min and max values this is expected. Try something like

.tickValues(d3.range(domain[0], domain[1]+1))

Here is a jsfiddle to play with

Upvotes: 3

Related Questions